Skip to content

Commit

Permalink
Pass a Uri to package:http APIs (#29)
Browse files Browse the repository at this point in the history
Prepare for dart-lang/http#375
  • Loading branch information
natebosch authored Dec 9, 2020
1 parent f1d1c9c commit 22c93ae
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/http_multi_server_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ void main() {
});

if (await supportsIPv4) {
expect(http.read('http://127.0.0.1:${server.port}/'),
expect(http.read(Uri.http('127.0.0.1:${server.port}', '/')),
completion(equals('got request')));
}

if (await supportsIPv6) {
expect(http.read('http://[::1]:${server.port}/'),
expect(http.read(Uri.http('[::1]:${server.port}', '/')),
completion(equals('got request')));
}
});
Expand All @@ -191,12 +191,12 @@ void main() {
});

if (await supportsIPv4) {
expect(http.read('http://127.0.0.1:${server.port}/'),
expect(http.read(Uri.http('127.0.0.1:${server.port}', '/')),
completion(equals('got request')));
}

if (await supportsIPv6) {
expect(http.read('http://[::1]:${server.port}/'),
expect(http.read(Uri.http('[::1]:${server.port}', '/')),
completion(equals('got request')));
}
});
Expand All @@ -209,12 +209,12 @@ void main() {
});

if (await supportsIPv4) {
expect(http.read('http://127.0.0.1:${server.port}/'),
expect(http.read(Uri.http('127.0.0.1:${server.port}', '/')),
completion(equals('got request')));
}

if (await supportsIPv6) {
expect(http.read('http://[::1]:${server.port}/'),
expect(http.read(Uri.http('[::1]:${server.port}', '/')),
completion(equals('got request')));
}
});
Expand All @@ -227,12 +227,12 @@ void main() {
});

if (await supportsIPv4) {
expect(http.read('http://127.0.0.1:${server.port}/'),
expect(http.read(Uri.http('127.0.0.1:${server.port}', '/')),
completion(equals('got request')));
}

if (await supportsIPv6) {
expect(http.read('http://[::1]:${server.port}/'),
expect(http.read(Uri.http('[::1]:${server.port}', '/')),
throwsA(isA<SocketException>()));
}
});
Expand All @@ -246,5 +246,5 @@ Future<http.Response> _get(HttpServer server) => http.get(_urlFor(server));
Future<String> _read(HttpServer server) => http.read(_urlFor(server));

/// Returns the URL for the root of [server].
String _urlFor(HttpServer server) =>
'http://${server.address.host}:${server.port}/';
Uri _urlFor(HttpServer server) =>
Uri.http('${server.address.host}:${server.port}', '/');

0 comments on commit 22c93ae

Please sign in to comment.