@@ -14,7 +14,6 @@ import 'exception.dart';
14
14
import 'request.dart' ;
15
15
import 'response.dart' ;
16
16
import 'streamed_response.dart' ;
17
- import 'utils.dart' ;
18
17
19
18
/// The abstract base class for an HTTP client. This is a mixin-style class;
20
19
/// subclasses only need to implement [send] and maybe [close] , and then they
@@ -150,27 +149,26 @@ abstract class BaseClient implements Client {
150
149
151
150
/// Sends a non-streaming [Request] and returns a non-streaming [Response] .
152
151
Future <Response > _sendUnstreamed (String method, url,
153
- Map <String , String > headers, [body, Encoding encoding]) {
154
- return syncFuture (() {
155
- if (url is String ) url = Uri .parse (url);
156
- var request = new Request (method, url);
157
-
158
- if (headers != null ) request.headers.addAll (headers);
159
- if (encoding != null ) request.encoding = encoding;
160
- if (body != null ) {
161
- if (body is String ) {
162
- request.body = body;
163
- } else if (body is List ) {
164
- request.bodyBytes = body;
165
- } else if (body is Map ) {
166
- request.bodyFields = body;
167
- } else {
168
- throw new ArgumentError ('Invalid request body "$body ".' );
169
- }
152
+ Map <String , String > headers, [body, Encoding encoding]) async {
153
+
154
+ if (url is String ) url = Uri .parse (url);
155
+ var request = new Request (method, url);
156
+
157
+ if (headers != null ) request.headers.addAll (headers);
158
+ if (encoding != null ) request.encoding = encoding;
159
+ if (body != null ) {
160
+ if (body is String ) {
161
+ request.body = body;
162
+ } else if (body is List ) {
163
+ request.bodyBytes = body;
164
+ } else if (body is Map ) {
165
+ request.bodyFields = body;
166
+ } else {
167
+ throw new ArgumentError ('Invalid request body "$body ".' );
170
168
}
169
+ }
171
170
172
- return send (request);
173
- }).then (Response .fromStream);
171
+ return Response .fromStream (await send (request));
174
172
}
175
173
176
174
/// Throws an error if [response] is not successful.
0 commit comments