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

Side by Side Diff: pkg/http/lib/src/mock_client.dart

Issue 16756002: Stop working around issue 2644. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/http/lib/src/base_client.dart ('k') | pkg/http/lib/src/utils.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library mock_client; 5 library mock_client;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'base_client.dart'; 10 import 'base_client.dart';
(...skipping 20 matching lines...) Expand all
31 31
32 /// Creates a [MockClient] with a handler that receives [Request]s and sends 32 /// Creates a [MockClient] with a handler that receives [Request]s and sends
33 /// [Response]s. 33 /// [Response]s.
34 MockClient(MockClientHandler fn) 34 MockClient(MockClientHandler fn)
35 : this._((baseRequest, bodyStream) { 35 : this._((baseRequest, bodyStream) {
36 return bodyStream.toBytes().then((bodyBytes) { 36 return bodyStream.toBytes().then((bodyBytes) {
37 var request = new Request(baseRequest.method, baseRequest.url); 37 var request = new Request(baseRequest.method, baseRequest.url);
38 request.persistentConnection = baseRequest.persistentConnection; 38 request.persistentConnection = baseRequest.persistentConnection;
39 request.followRedirects = baseRequest.followRedirects; 39 request.followRedirects = baseRequest.followRedirects;
40 request.maxRedirects = baseRequest.maxRedirects; 40 request.maxRedirects = baseRequest.maxRedirects;
41 mapAddAll(request.headers, baseRequest.headers); 41 request.headers.addAll(baseRequest.headers);
42 request.bodyBytes = bodyBytes; 42 request.bodyBytes = bodyBytes;
43 request.finalize(); 43 request.finalize();
44 44
45 return fn(request); 45 return fn(request);
46 }).then((response) { 46 }).then((response) {
47 return new StreamedResponse( 47 return new StreamedResponse(
48 new ByteStream.fromBytes(response.bodyBytes), 48 new ByteStream.fromBytes(response.bodyBytes),
49 response.statusCode, 49 response.statusCode,
50 response.contentLength, 50 response.contentLength,
51 request: baseRequest, 51 request: baseRequest,
(...skipping 29 matching lines...) Expand all
81 } 81 }
82 82
83 /// A handler function that receives [StreamedRequest]s and sends 83 /// A handler function that receives [StreamedRequest]s and sends
84 /// [StreamedResponse]s. Note that [request] will be finalized. 84 /// [StreamedResponse]s. Note that [request] will be finalized.
85 typedef Future<StreamedResponse> MockClientStreamHandler( 85 typedef Future<StreamedResponse> MockClientStreamHandler(
86 BaseRequest request, ByteStream bodyStream); 86 BaseRequest request, ByteStream bodyStream);
87 87
88 /// A handler function that receives [Request]s and sends [Response]s. Note that 88 /// A handler function that receives [Request]s and sends [Response]s. Note that
89 /// [request] will be finalized. 89 /// [request] will be finalized.
90 typedef Future<Response> MockClientHandler(Request request); 90 typedef Future<Response> MockClientHandler(Request request);
OLDNEW
« no previous file with comments | « pkg/http/lib/src/base_client.dart ('k') | pkg/http/lib/src/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698