Index: pkg/http/lib/src/io_client.dart |
diff --git a/pkg/http/lib/src/io_client.dart b/pkg/http/lib/src/io_client.dart |
index 9fd81acdfa865e1899dc26622edfdac8ca461989..34f622366c6d3fed76b4d5b3b4fdf699ecb5b965 100644 |
--- a/pkg/http/lib/src/io_client.dart |
+++ b/pkg/http/lib/src/io_client.dart |
@@ -20,9 +20,19 @@ class IOClient extends BaseClient { |
var _inner; |
/// Creates a new HTTP client. |
- IOClient() { |
+ /// |
+ /// [innerClient] must be a `dart:io` HTTP client. If it's not passed, a |
+ /// default one will be instantiated. |
+ IOClient([innerClient]) { |
io.assertSupported("IOClient"); |
- _inner = io.newHttpClient(); |
+ if (innerClient != null) { |
+ // TODO(nweiz): remove this assert when we can type [innerClient] |
+ // properly. |
+ assert(io.isHttpClient(innerClient)); |
+ _inner = innerClient; |
+ } else { |
+ _inner = io.newHttpClient(); |
+ } |
} |
/// Sends an HTTP request and asynchronously returns the response. |