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

Unified Diff: lib/src/base_client.dart

Issue 1306723008: pkg/http: Removed uses of Chain.track (Closed) Base URL: https://github.com/dart-lang/http.git@master
Patch Set: sdk version oops Created 5 years, 4 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 | « CHANGELOG.md ('k') | lib/src/io_client.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/base_client.dart
diff --git a/lib/src/base_client.dart b/lib/src/base_client.dart
index ad85a67114194911e1fbb3a750268ea6cd987476..104d702473a1c6efa5942be03af61d75775be6f8 100644
--- a/lib/src/base_client.dart
+++ b/lib/src/base_client.dart
@@ -14,7 +14,6 @@ import 'exception.dart';
import 'request.dart';
import 'response.dart';
import 'streamed_response.dart';
-import 'utils.dart';
/// The abstract base class for an HTTP client. This is a mixin-style class;
/// subclasses only need to implement [send] and maybe [close], and then they
@@ -150,27 +149,26 @@ abstract class BaseClient implements Client {
/// Sends a non-streaming [Request] and returns a non-streaming [Response].
Future<Response> _sendUnstreamed(String method, url,
- Map<String, String> headers, [body, Encoding encoding]) {
- return syncFuture(() {
- if (url is String) url = Uri.parse(url);
- var request = new Request(method, url);
-
- if (headers != null) request.headers.addAll(headers);
- if (encoding != null) request.encoding = encoding;
- if (body != null) {
- if (body is String) {
- request.body = body;
- } else if (body is List) {
- request.bodyBytes = body;
- } else if (body is Map) {
- request.bodyFields = body;
- } else {
- throw new ArgumentError('Invalid request body "$body".');
- }
+ Map<String, String> headers, [body, Encoding encoding]) async {
+
+ if (url is String) url = Uri.parse(url);
+ var request = new Request(method, url);
+
+ if (headers != null) request.headers.addAll(headers);
+ if (encoding != null) request.encoding = encoding;
+ if (body != null) {
+ if (body is String) {
+ request.body = body;
+ } else if (body is List) {
+ request.bodyBytes = body;
+ } else if (body is Map) {
+ request.bodyFields = body;
+ } else {
+ throw new ArgumentError('Invalid request body "$body".');
}
+ }
- return send(request);
- }).then(Response.fromStream);
+ return Response.fromStream(await send(request));
}
/// Throws an error if [response] is not successful.
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/io_client.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698