Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(424)

Unified Diff: pkg/http/lib/src/io_client.dart

Issue 299483002: Support a user-supplied dart:io client in pkg/http. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/http/lib/src/io.dart ('k') | pkg/http/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « pkg/http/lib/src/io.dart ('k') | pkg/http/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698