Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 33 additions & 37 deletions pkgs/cupertino_http/test/url_session_delegate_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -380,43 +380,39 @@ void testOnRedirect(URLSessionConfiguration Function() config) {
session.finishTasksAndInvalidate();
});

test(
'exception in http redirection',
() async {
final session = URLSession.sessionWithConfiguration(
config(),
onRedirect:
(redirectSession, redirectTask, redirectResponse, newRequest) {
throw UnimplementedError();
},
);
final c = Completer<void>();
URLResponse? response;
// ignore: unused_local_variable
NSError? error;

session.dataTaskWithCompletionHandler(
URLRequest.fromUrl(
Uri.parse('http://localhost:${redirectServer.port}/100'),
),
(d, r, e) {
response = r;
error = e;
c.complete();
},
).resume();
await c.future;

expect(
response,
isA<HTTPURLResponse>().having((r) => r.statusCode, 'statusCode', 302),
);
// TODO(https://github.com/dart-lang/ffigen/issues/386): Check that the
// error is set.
session.finishTasksAndInvalidate();
},
skip: 'Error not set for redirect exceptions.',
);
test('exception in http redirection', () async {
final session = URLSession.sessionWithConfiguration(
config(),
onRedirect:
(redirectSession, redirectTask, redirectResponse, newRequest) {
throw UnimplementedError();
},
);
final c = Completer<void>();
URLResponse? response;
// ignore: unused_local_variable
NSError? error;

session.dataTaskWithCompletionHandler(
URLRequest.fromUrl(
Uri.parse('http://localhost:${redirectServer.port}/100'),
),
(d, r, e) {
response = r;
error = e;
c.complete();
},
).resume();
await c.future;

expect(
response,
isA<HTTPURLResponse>().having((r) => r.statusCode, 'statusCode', 302),
);
// TODO(https://github.com/dart-lang/ffigen/issues/386): Check that the
// error is set.
session.finishTasksAndInvalidate();
}, skip: 'Error not set for redirect exceptions.');

test('3 redirects', () async {
var redirectCounter = 0;
Expand Down
Loading