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

Side by Side Diff: pkg/http/lib/src/base_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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/http/lib/http.dart ('k') | pkg/http/lib/src/base_request.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 base_client; 5 library base_client;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:scalarlist'; 9 import 'dart:scalarlist';
10 import 'dart:uri'; 10 import 'dart:uri';
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 Future<Uint8List> readBytes(url, {Map<String, String> headers}) { 91 Future<Uint8List> readBytes(url, {Map<String, String> headers}) {
92 return get(url, headers: headers).then((response) { 92 return get(url, headers: headers).then((response) {
93 _checkResponseSuccess(url, response); 93 _checkResponseSuccess(url, response);
94 return response.bodyBytes; 94 return response.bodyBytes;
95 }); 95 });
96 } 96 }
97 97
98 /// Sends an HTTP request and asynchronously returns the response. 98 /// Sends an HTTP request and asynchronously returns the response.
99 /// 99 ///
100 /// Implementers should call [BaseRequest.finalize] to get the body of the 100 /// Implementers should call [BaseRequest.finalize] to get the body of the
101 /// request as an [InputStream]. They shouldn't make any assumptions about the 101 /// request as a [ByteStream]. They shouldn't make any assumptions about the
102 /// state of the stream; it could have data written to it asynchronously at a 102 /// state of the stream; it could have data written to it asynchronously at a
103 /// later point, or it could already be closed when it's returned. 103 /// later point, or it could already be closed when it's returned.
104 Future<StreamedResponse> send(BaseRequest request); 104 Future<StreamedResponse> send(BaseRequest request);
105 105
106 /// Sends a non-streaming [Request] and returns a non-streaming [Response]. 106 /// Sends a non-streaming [Request] and returns a non-streaming [Response].
107 Future<Response> _sendUnstreamed( 107 Future<Response> _sendUnstreamed(
108 String method, url, Map<String, String> headers, 108 String method, url, Map<String, String> headers,
109 [Map<String, String> fields]) { 109 [Map<String, String> fields]) {
110 // Wrap everything in a Future block so that synchronous validation errors 110 // Wrap everything in a Future block so that synchronous validation errors
111 // are passed asynchronously through the Future chain. 111 // are passed asynchronously through the Future chain.
(...skipping 16 matching lines...) Expand all
128 message = "$message: ${response.reasonPhrase}"; 128 message = "$message: ${response.reasonPhrase}";
129 } 129 }
130 throw new HttpException("$message."); 130 throw new HttpException("$message.");
131 } 131 }
132 132
133 /// Closes the client and cleans up any resources associated with it. It's 133 /// Closes the client and cleans up any resources associated with it. It's
134 /// important to close each client when it's done being used; failing to do so 134 /// important to close each client when it's done being used; failing to do so
135 /// can cause the Dart process to hang. 135 /// can cause the Dart process to hang.
136 void close() {} 136 void close() {}
137 } 137 }
OLDNEW
« no previous file with comments | « pkg/http/lib/http.dart ('k') | pkg/http/lib/src/base_request.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698