Skip to content

Commit ef05b37

Browse files
authored
[cupertino_http]: Switch to ffigen 19.1.0 (#1811)
1 parent 6656f15 commit ef05b37

32 files changed

+57788
-42529
lines changed

.github/workflows/cupertino.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
matrix:
3434
# Test on the minimum supported flutter version and the latest
3535
# version.
36-
flutter-version: ["3.24.0", "any"]
36+
flutter-version: ["3.32.0", "any"]
3737
# It would be nice to test on older versions of macOS but macOS 13 is
3838
# the oldest supported by GitHub.
3939
os: [macos-13, macos-latest]
@@ -68,7 +68,7 @@ jobs:
6868
matrix:
6969
# Test on the minimum supported flutter version and the latest
7070
# version.
71-
flutter-version: ["3.24.0", "any"]
71+
flutter-version: ["3.32.0", "any"]
7272
steps:
7373
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
7474
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e

pkgs/cupertino_http/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.4.0-wip
2+
3+
* Switch to `package:objective_c` `8.1.0` and `package:ffigen` `19.1.0`.
4+
15
## 2.3.0
26

37
* Add the ability to abort requests.

pkgs/cupertino_http/darwin/cupertino_http/Sources/cupertino_http/native_cupertino_bindings.m

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkgs/cupertino_http/example/integration_test/client_profile_test.dart

Lines changed: 95 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ void main() {
4141
});
4242
successServerUri = Uri.http('localhost:${successServer.port}');
4343
final client = CupertinoClientWithProfile.defaultSessionConfiguration();
44-
await client.post(successServerUri,
45-
headers: {'Content-Type': 'text/plain'}, body: 'Hi');
44+
await client.post(
45+
successServerUri,
46+
headers: {'Content-Type': 'text/plain'},
47+
body: 'Hi',
48+
);
4649
profile = client.profile!;
4750
});
4851
tearDownAll(() {
@@ -53,8 +56,10 @@ void main() {
5356
expect(profile.events, isEmpty);
5457
expect(profile.requestMethod, 'POST');
5558
expect(profile.requestUri, successServerUri.toString());
56-
expect(profile.connectionInfo,
57-
containsPair('package', 'package:cupertino_http'));
59+
expect(
60+
profile.connectionInfo,
61+
containsPair('package', 'package:cupertino_http'),
62+
);
5863
});
5964

6065
test('request attributes', () {
@@ -63,9 +68,13 @@ void main() {
6368
expect(profile.requestData.endTime, isNotNull);
6469
expect(profile.requestData.error, isNull);
6570
expect(
66-
profile.requestData.headers, containsPair('Content-Length', ['2']));
67-
expect(profile.requestData.headers,
68-
containsPair('Content-Type', ['text/plain; charset=utf-8']));
71+
profile.requestData.headers,
72+
containsPair('Content-Length', ['2']),
73+
);
74+
expect(
75+
profile.requestData.headers,
76+
containsPair('Content-Type', ['text/plain; charset=utf-8']),
77+
);
6978
expect(profile.requestData.persistentConnection, isNull);
7079
expect(profile.requestData.proxyDetails, isNull);
7180
expect(profile.requestData.startTime, isNotNull);
@@ -77,10 +86,14 @@ void main() {
7786
expect(profile.responseData.contentLength, 11);
7887
expect(profile.responseData.endTime, isNotNull);
7988
expect(profile.responseData.error, isNull);
80-
expect(profile.responseData.headers,
81-
containsPair('content-type', ['text/plain']));
82-
expect(profile.responseData.headers,
83-
containsPair('content-length', ['11']));
89+
expect(
90+
profile.responseData.headers,
91+
containsPair('content-type', ['text/plain']),
92+
);
93+
expect(
94+
profile.responseData.headers,
95+
containsPair('content-length', ['11']),
96+
);
8497
expect(profile.responseData.isRedirect, false);
8598
expect(profile.responseData.persistentConnection, isNull);
8699
expect(profile.responseData.reasonPhrase, 'OK');
@@ -119,7 +132,8 @@ void main() {
119132
}
120133
}();
121134
unawaited(
122-
request.sink.addStream(stream).then((_) => request.sink.close()));
135+
request.sink.addStream(stream).then((_) => request.sink.close()),
136+
);
123137

124138
await client.send(request);
125139
profile = client.profile!;
@@ -143,8 +157,11 @@ void main() {
143157
setUpAll(() async {
144158
final client = CupertinoClientWithProfile.defaultSessionConfiguration();
145159
try {
146-
await client.post(Uri.http('thisisnotahost'),
147-
headers: {'Content-Type': 'text/plain'}, body: 'Hi');
160+
await client.post(
161+
Uri.http('thisisnotahost'),
162+
headers: {'Content-Type': 'text/plain'},
163+
body: 'Hi',
164+
);
148165
fail('expected exception');
149166
} on ClientException {
150167
// Expected exception.
@@ -156,20 +173,28 @@ void main() {
156173
expect(profile.events, isEmpty);
157174
expect(profile.requestMethod, 'POST');
158175
expect(profile.requestUri, 'http://thisisnotahost');
159-
expect(profile.connectionInfo,
160-
containsPair('package', 'package:cupertino_http'));
176+
expect(
177+
profile.connectionInfo,
178+
containsPair('package', 'package:cupertino_http'),
179+
);
161180
});
162181

163182
test('request attributes', () {
164183
expect(profile.requestData.bodyBytes, 'Hi'.codeUnits);
165184
expect(profile.requestData.contentLength, 2);
166185
expect(profile.requestData.endTime, isNotNull);
167186
expect(
168-
profile.requestData.error, startsWith('NSErrorClientException:'));
187+
profile.requestData.error,
188+
startsWith('NSErrorClientException:'),
189+
);
190+
expect(
191+
profile.requestData.headers,
192+
containsPair('Content-Length', ['2']),
193+
);
169194
expect(
170-
profile.requestData.headers, containsPair('Content-Length', ['2']));
171-
expect(profile.requestData.headers,
172-
containsPair('Content-Type', ['text/plain; charset=utf-8']));
195+
profile.requestData.headers,
196+
containsPair('Content-Type', ['text/plain; charset=utf-8']),
197+
);
173198
expect(profile.requestData.persistentConnection, isNull);
174199
expect(profile.requestData.proxyDetails, isNull);
175200
expect(profile.requestData.startTime, isNotNull);
@@ -209,8 +234,11 @@ void main() {
209234
final client = CupertinoClientWithProfile.defaultSessionConfiguration();
210235

211236
try {
212-
await client.post(successServerUri,
213-
headers: {'Content-Type': 'text/plain'}, body: 'Hi');
237+
await client.post(
238+
successServerUri,
239+
headers: {'Content-Type': 'text/plain'},
240+
body: 'Hi',
241+
);
214242
fail('expected exception');
215243
} on ClientException {
216244
// Expected exception.
@@ -225,8 +253,10 @@ void main() {
225253
expect(profile.events, isEmpty);
226254
expect(profile.requestMethod, 'POST');
227255
expect(profile.requestUri, successServerUri.toString());
228-
expect(profile.connectionInfo,
229-
containsPair('package', 'package:cupertino_http'));
256+
expect(
257+
profile.connectionInfo,
258+
containsPair('package', 'package:cupertino_http'),
259+
);
230260
});
231261

232262
test('request attributes', () {
@@ -235,9 +265,13 @@ void main() {
235265
expect(profile.requestData.endTime, isNotNull);
236266
expect(profile.requestData.error, isNull);
237267
expect(
238-
profile.requestData.headers, containsPair('Content-Length', ['2']));
239-
expect(profile.requestData.headers,
240-
containsPair('Content-Type', ['text/plain; charset=utf-8']));
268+
profile.requestData.headers,
269+
containsPair('Content-Length', ['2']),
270+
);
271+
expect(
272+
profile.requestData.headers,
273+
containsPair('Content-Type', ['text/plain; charset=utf-8']),
274+
);
241275
expect(profile.requestData.persistentConnection, isNull);
242276
expect(profile.requestData.proxyDetails, isNull);
243277
expect(profile.requestData.startTime, isNotNull);
@@ -249,11 +283,17 @@ void main() {
249283
expect(profile.responseData.contentLength, 11);
250284
expect(profile.responseData.endTime, isNotNull);
251285
expect(
252-
profile.responseData.error, startsWith('NSErrorClientException:'));
253-
expect(profile.responseData.headers,
254-
containsPair('content-type', ['text/plain']));
255-
expect(profile.responseData.headers,
256-
containsPair('content-length', ['11']));
286+
profile.responseData.error,
287+
startsWith('NSErrorClientException:'),
288+
);
289+
expect(
290+
profile.responseData.headers,
291+
containsPair('content-type', ['text/plain']),
292+
);
293+
expect(
294+
profile.responseData.headers,
295+
containsPair('content-length', ['11']),
296+
);
257297
expect(profile.responseData.isRedirect, false);
258298
expect(profile.responseData.persistentConnection, isNull);
259299
expect(profile.responseData.reasonPhrase, 'OK');
@@ -325,8 +365,11 @@ void main() {
325365
} else {
326366
final n = int.parse(request.requestedUri.pathSegments.last);
327367
final nextPath = n - 1 == 0 ? '' : '${n - 1}';
328-
unawaited(request.response
329-
.redirect(successServerUri.replace(path: '/$nextPath')));
368+
unawaited(
369+
request.response.redirect(
370+
successServerUri.replace(path: '/$nextPath'),
371+
),
372+
);
330373
}
331374
});
332375
successServerUri = Uri.http('localhost:${successServer.port}');
@@ -345,9 +388,11 @@ void main() {
345388

346389
test('follow redirects', () async {
347390
final client = CupertinoClientWithProfile.defaultSessionConfiguration();
348-
await client.send(Request('GET', successServerUri.replace(path: '/3'))
349-
..followRedirects = true
350-
..maxRedirects = 4);
391+
await client.send(
392+
Request('GET', successServerUri.replace(path: '/3'))
393+
..followRedirects = true
394+
..maxRedirects = 4,
395+
);
351396
profile = client.profile!;
352397

353398
expect(profile.requestData.followRedirects, true);
@@ -356,25 +401,29 @@ void main() {
356401

357402
expect(profile.responseData.redirects, [
358403
HttpProfileRedirectData(
359-
statusCode: 302,
360-
method: 'GET',
361-
location: successServerUri.replace(path: '/2').toString()),
404+
statusCode: 302,
405+
method: 'GET',
406+
location: successServerUri.replace(path: '/2').toString(),
407+
),
362408
HttpProfileRedirectData(
363-
statusCode: 302,
364-
method: 'GET',
365-
location: successServerUri.replace(path: '/1').toString()),
409+
statusCode: 302,
410+
method: 'GET',
411+
location: successServerUri.replace(path: '/1').toString(),
412+
),
366413
HttpProfileRedirectData(
367414
statusCode: 302,
368415
method: 'GET',
369416
location: successServerUri.replace(path: '/').toString(),
370-
)
417+
),
371418
]);
372419
});
373420

374421
test('no follow redirects', () async {
375422
final client = CupertinoClientWithProfile.defaultSessionConfiguration();
376-
await client.send(Request('GET', successServerUri.replace(path: '/3'))
377-
..followRedirects = false);
423+
await client.send(
424+
Request('GET', successServerUri.replace(path: '/3'))
425+
..followRedirects = false,
426+
);
378427
profile = client.profile!;
379428

380429
expect(profile.requestData.followRedirects, false);

pkgs/cupertino_http/example/integration_test/http_url_response_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ void main() {
2626
});
2727
final session = URLSession.sharedSession();
2828
final task = session.dataTaskWithRequest(
29-
URLRequest.fromUrl(Uri.parse('http://localhost:${server.port}')))
30-
..resume();
31-
while (
32-
task.state != NSURLSessionTaskState.NSURLSessionTaskStateCompleted) {
29+
URLRequest.fromUrl(Uri.parse('http://localhost:${server.port}')),
30+
)..resume();
31+
while (task.state !=
32+
NSURLSessionTaskState.NSURLSessionTaskStateCompleted) {
3333
// Let the event loop run.
3434
await Future<void>(() {});
3535
}

pkgs/cupertino_http/example/integration_test/main.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import 'url_session_configuration_test.dart' as url_session_configuration_test;
1616
import 'url_session_delegate_test.dart' as url_session_delegate_test;
1717
import 'url_session_task_test.dart' as url_session_task_test;
1818
import 'url_session_test.dart' as url_session_test;
19-
import 'utils_test.dart' as utils_test;
2019
import 'web_socket_conformance_test.dart' as web_socket_conformance_test;
2120

2221
/// Execute all the tests in this directory.
@@ -39,6 +38,5 @@ void main() {
3938
url_session_delegate_test.main();
4039
url_session_task_test.main();
4140
url_session_test.main();
42-
utils_test.main();
4341
web_socket_conformance_test.main();
4442
}

pkgs/cupertino_http/example/integration_test/mutable_url_request_test.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ void main() {
2121
test('set', () {
2222
request.cachePolicy =
2323
NSURLRequestCachePolicy.NSURLRequestReturnCacheDataDontLoad;
24-
expect(request.cachePolicy,
25-
NSURLRequestCachePolicy.NSURLRequestReturnCacheDataDontLoad);
24+
expect(
25+
request.cachePolicy,
26+
NSURLRequestCachePolicy.NSURLRequestReturnCacheDataDontLoad,
27+
);
2628
request.toString(); // Just verify that there is no crash.
2729
});
2830
});

pkgs/cupertino_http/example/integration_test/ns_error_client_exception.dart

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,25 @@ void main() {
1818

1919
test('thrown', () async {
2020
expect(
21-
() => client.get(Uri.http('doesnotexist', '/')),
22-
throwsA(isA<NSErrorClientException>()
23-
.having((e) => e.error.domain.toDartString(), 'error.domain',
24-
'NSURLErrorDomain')
21+
() => client.get(Uri.http('doesnotexist', '/')),
22+
throwsA(
23+
isA<NSErrorClientException>()
24+
.having(
25+
(e) => e.error.domain.toDartString(),
26+
'error.domain',
27+
'NSURLErrorDomain',
28+
)
2529
.having((e) => e.error.code, 'error.code', -1003)
2630
.having(
27-
(e) => e.toString(),
28-
'toString()',
29-
'NSErrorClientException: A server with the specified '
30-
'hostname could not be found. '
31-
'[domain=NSURLErrorDomain, code=-1003], '
32-
'uri=http://doesnotexist/')));
31+
(e) => e.toString(),
32+
'toString()',
33+
'NSErrorClientException: A server with the specified '
34+
'hostname could not be found. '
35+
'[domain=NSURLErrorDomain, code=-1003], '
36+
'uri=http://doesnotexist/',
37+
),
38+
),
39+
);
3340
});
3441
});
3542
}

pkgs/cupertino_http/example/integration_test/url_cache_test.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ void main() {
3838
});
3939

4040
Future<void> doRequest(URLSession session) {
41-
final request =
42-
URLRequest.fromUrl(Uri.parse('http://localhost:${server.port}'));
41+
final request = URLRequest.fromUrl(
42+
Uri.parse('http://localhost:${server.port}'),
43+
);
4344
final c = Completer<void>();
4445
session.dataTaskWithCompletionHandler(request, (d, r, e) {
4546
c.complete();

0 commit comments

Comments
 (0)