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

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

Issue 11825010: Update pkg/http to use the new async APIs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 7 years, 11 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/byte_stream.dart ('k') | pkg/http/lib/src/mock_client.dart » ('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 d5b40cba517ace3c10b1c6ca0d1b4ee450abdcc5..8cc775a351a46764eba084a1185ff6d613beeb61 100644
--- a/pkg/http/lib/src/io_client.dart
+++ b/pkg/http/lib/src/io_client.dart
@@ -42,6 +42,7 @@ class IOClient extends BaseClient {
});
};
+ var pipeCompleter = new Completer();
connection.onRequest = (underlyingRequest) {
underlyingRequest.contentLength = request.contentLength;
underlyingRequest.persistentConnection = request.persistentConnection;
@@ -49,11 +50,9 @@ class IOClient extends BaseClient {
underlyingRequest.headers.set(name, value);
});
- if (stream.closed) {
- underlyingRequest.outputStream.close();
- } else {
- stream.pipe(underlyingRequest.outputStream);
- }
+ chainToCompleter(
+ stream.pipe(wrapOutputStream(underlyingRequest.outputStream)),
+ pipeCompleter);
};
connection.onResponse = (response) {
@@ -64,7 +63,7 @@ class IOClient extends BaseClient {
completed = true;
completer.complete(new StreamedResponse(
- response.inputStream,
+ wrapInputStream(response.inputStream),
response.statusCode,
response.contentLength,
request: request,
@@ -74,7 +73,7 @@ class IOClient extends BaseClient {
reasonPhrase: response.reasonPhrase));
};
- return completer.future;
+ return pipeCompleter.future.then((_) => completer.future);
}
/// Closes the client. This terminates all active connections. If a client
« no previous file with comments | « pkg/http/lib/src/byte_stream.dart ('k') | pkg/http/lib/src/mock_client.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698