Skip to content

Commit 6cf06ea

Browse files
committed
Use Future in http helpers
1 parent 949bb56 commit 6cf06ea

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

lib/http.dart

+9-13
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import 'src/client.dart';
1111
import 'src/response.dart';
1212

1313
export 'src/base_client.dart';
14-
export 'src/base_request.dart';
15-
export 'src/base_response.dart';
1614
export 'src/byte_stream.dart';
1715
export 'src/client.dart';
1816
export 'src/exception.dart';
@@ -21,8 +19,6 @@ export 'src/multipart_file.dart';
2119
export 'src/multipart_request.dart';
2220
export 'src/request.dart';
2321
export 'src/response.dart';
24-
export 'src/streamed_request.dart';
25-
export 'src/streamed_response.dart';
2622

2723
/// Sends an HTTP HEAD request with the given headers to the given URL, which
2824
/// can be a [Uri] or a [String].
@@ -32,7 +28,7 @@ export 'src/streamed_response.dart';
3228
/// the same server, you should use a single [Client] for all of those requests.
3329
///
3430
/// For more fine-grained control over the request, use [Request] instead.
35-
FutureOr<Response> head(url, {Map<String, String> headers}) =>
31+
Future<Response> head(url, {Map<String, String> headers}) =>
3632
_withClient((client) => client.head(url, headers: headers));
3733

3834
/// Sends an HTTP GET request with the given headers to the given URL, which can
@@ -43,7 +39,7 @@ FutureOr<Response> head(url, {Map<String, String> headers}) =>
4339
/// the same server, you should use a single [Client] for all of those requests.
4440
///
4541
/// For more fine-grained control over the request, use [Request] instead.
46-
FutureOr<Response> get(url, {Map<String, String> headers}) =>
42+
Future<Response> get(url, {Map<String, String> headers}) =>
4743
_withClient((client) => client.get(url, headers: headers));
4844

4945
/// Sends an HTTP POST request with the given headers and body to the given URL,
@@ -65,7 +61,7 @@ FutureOr<Response> get(url, {Map<String, String> headers}) =>
6561
///
6662
/// For more fine-grained control over the request, use [Request] or
6763
/// [StreamedRequest] instead.
68-
FutureOr<Response> post(url, body, {Map<String, String> headers,
64+
Future<Response> post(url, body, {Map<String, String> headers,
6965
Encoding encoding}) =>
7066
_withClient((client) => client.post(url, body,
7167
headers: headers, encoding: encoding));
@@ -89,7 +85,7 @@ FutureOr<Response> post(url, body, {Map<String, String> headers,
8985
///
9086
/// For more fine-grained control over the request, use [Request] or
9187
/// [StreamedRequest] instead.
92-
FutureOr<Response> put(url, body, {Map<String, String> headers,
88+
Future<Response> put(url, body, {Map<String, String> headers,
9389
Encoding encoding}) =>
9490
_withClient((client) => client.put(url, body,
9591
headers: headers, encoding: encoding));
@@ -113,7 +109,7 @@ FutureOr<Response> put(url, body, {Map<String, String> headers,
113109
///
114110
/// For more fine-grained control over the request, use [Request] or
115111
/// [StreamedRequest] instead.
116-
FutureOr<Response> patch(url, body, {Map<String, String> headers,
112+
Future<Response> patch(url, body, {Map<String, String> headers,
117113
Encoding encoding}) =>
118114
_withClient((client) => client.patch(url, body,
119115
headers: headers, encoding: encoding));
@@ -126,7 +122,7 @@ FutureOr<Response> patch(url, body, {Map<String, String> headers,
126122
/// the same server, you should use a single [Client] for all of those requests.
127123
///
128124
/// For more fine-grained control over the request, use [Request] instead.
129-
FutureOr<Response> delete(url, {Map<String, String> headers}) =>
125+
Future<Response> delete(url, {Map<String, String> headers}) =>
130126
_withClient((client) => client.delete(url, headers: headers));
131127

132128
/// Sends an HTTP GET request with the given headers to the given URL, which can
@@ -142,7 +138,7 @@ FutureOr<Response> delete(url, {Map<String, String> headers}) =>
142138
///
143139
/// For more fine-grained control over the request and response, use [Request]
144140
/// instead.
145-
FutureOr<String> read(url, {Map<String, String> headers}) =>
141+
Future<String> read(url, {Map<String, String> headers}) =>
146142
_withClient((client) => client.read(url, headers: headers));
147143

148144
/// Sends an HTTP GET request with the given headers to the given URL, which can
@@ -158,10 +154,10 @@ FutureOr<String> read(url, {Map<String, String> headers}) =>
158154
///
159155
/// For more fine-grained control over the request and response, use [Request]
160156
/// instead.
161-
FutureOr<Uint8List> readBytes(url, {Map<String, String> headers}) =>
157+
Future<Uint8List> readBytes(url, {Map<String, String> headers}) =>
162158
_withClient((client) => client.readBytes(url, headers: headers));
163159

164-
FutureOr<T> _withClient<T>(FutureOr<T> fn(Client client)) async {
160+
Future<T> _withClient<T>(FutureOr<T> fn(Client client)) async {
165161
var client = new Client();
166162
try {
167163
return await fn(client);

0 commit comments

Comments
 (0)