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

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

Issue 1944603004: Fix one final strong-mode warning. (Closed) Base URL: git@github.com:dart-lang/http@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « CHANGELOG.md ('k') | 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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'base_client.dart'; 7 import 'base_client.dart';
8 import 'base_request.dart'; 8 import 'base_request.dart';
9 import 'byte_stream.dart'; 9 import 'byte_stream.dart';
10 import 'request.dart'; 10 import 'request.dart';
11 import 'response.dart'; 11 import 'response.dart';
12 import 'streamed_response.dart'; 12 import 'streamed_response.dart';
13 import 'utils.dart';
14 13
15 // TODO(nweiz): once Dart has some sort of Rack- or WSGI-like standard for 14 // TODO(nweiz): once Dart has some sort of Rack- or WSGI-like standard for
16 // server APIs, MockClient should conform to it. 15 // server APIs, MockClient should conform to it.
17 16
18 /// A mock HTTP client designed for use when testing code that uses 17 /// A mock HTTP client designed for use when testing code that uses
19 /// [BaseClient]. This client allows you to define a handler callback for all 18 /// [BaseClient]. This client allows you to define a handler callback for all
20 /// requests that are made through it so that you can mock a server without 19 /// requests that are made through it so that you can mock a server without
21 /// having to send real HTTP requests. 20 /// having to send real HTTP requests.
22 class MockClient extends BaseClient { 21 class MockClient extends BaseClient {
23 /// The handler for receiving [StreamedRequest]s and sending 22 /// The handler for receiving [StreamedRequest]s and sending
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 contentLength: response.contentLength, 63 contentLength: response.contentLength,
65 request: request, 64 request: request,
66 headers: response.headers, 65 headers: response.headers,
67 isRedirect: response.isRedirect, 66 isRedirect: response.isRedirect,
68 persistentConnection: response.persistentConnection, 67 persistentConnection: response.persistentConnection,
69 reasonPhrase: response.reasonPhrase); 68 reasonPhrase: response.reasonPhrase);
70 }); 69 });
71 }); 70 });
72 71
73 /// Sends a request. 72 /// Sends a request.
74 Future<StreamedResponse> send(BaseRequest request) { 73 Future<StreamedResponse> send(BaseRequest request) async {
75 var bodyStream = request.finalize(); 74 var bodyStream = request.finalize();
76 return async.then((_) => _handler(request, bodyStream)); 75 return await _handler(request, bodyStream);
77 } 76 }
78 } 77 }
79 78
80 /// A handler function that receives [StreamedRequest]s and sends 79 /// A handler function that receives [StreamedRequest]s and sends
81 /// [StreamedResponse]s. Note that [request] will be finalized. 80 /// [StreamedResponse]s. Note that [request] will be finalized.
82 typedef Future<StreamedResponse> MockClientStreamHandler( 81 typedef Future<StreamedResponse> MockClientStreamHandler(
83 BaseRequest request, ByteStream bodyStream); 82 BaseRequest request, ByteStream bodyStream);
84 83
85 /// A handler function that receives [Request]s and sends [Response]s. Note that 84 /// A handler function that receives [Request]s and sends [Response]s. Note that
86 /// [request] will be finalized. 85 /// [request] will be finalized.
87 typedef Future<Response> MockClientHandler(Request request); 86 typedef Future<Response> MockClientHandler(Request request);
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698