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

Unified Diff: pkg/http/lib/src/mock_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/io_client.dart ('k') | pkg/http/lib/src/multipart_file.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/lib/src/mock_client.dart
diff --git a/pkg/http/lib/src/mock_client.dart b/pkg/http/lib/src/mock_client.dart
index 8af54743948bfcc2f47c918595818e2b137f4b50..91c0dc09c950d374115d98005d7b207f0c65535b 100644
--- a/pkg/http/lib/src/mock_client.dart
+++ b/pkg/http/lib/src/mock_client.dart
@@ -9,6 +9,7 @@ import 'dart:io';
import 'base_client.dart';
import 'base_request.dart';
+import 'byte_stream.dart';
import 'request.dart';
import 'response.dart';
import 'streamed_response.dart';
@@ -32,7 +33,7 @@ class MockClient extends BaseClient {
/// [Response]s.
MockClient(MockClientHandler fn)
: this._((baseRequest, bodyStream) {
- return consumeInputStream(bodyStream).then((bodyBytes) {
+ return bodyStream.toBytes().then((bodyBytes) {
var request = new Request(baseRequest.method, baseRequest.url);
request.persistentConnection = baseRequest.persistentConnection;
request.followRedirects = baseRequest.followRedirects;
@@ -43,12 +44,8 @@ class MockClient extends BaseClient {
return fn(request);
}).then((response) {
- var stream = new ListInputStream();
- stream.write(response.bodyBytes);
- stream.markEndOfStream();
-
return new StreamedResponse(
- stream,
+ new ByteStream.fromBytes(response.bodyBytes),
response.statusCode,
response.contentLength,
request: baseRequest,
@@ -86,7 +83,7 @@ class MockClient extends BaseClient {
/// A handler function that receives [StreamedRequest]s and sends
/// [StreamedResponse]s. Note that [request] will be finalized.
typedef Future<StreamedResponse> MockClientStreamHandler(
- BaseRequest request, InputStream bodyStream);
+ BaseRequest request, ByteStream bodyStream);
/// A handler function that receives [Request]s and sends [Response]s. Note that
/// [request] will be finalized.
« no previous file with comments | « pkg/http/lib/src/io_client.dart ('k') | pkg/http/lib/src/multipart_file.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698