@@ -10,6 +10,7 @@ import 'dart:typed_data';
10
10
11
11
import 'src/client.dart' ;
12
12
import 'src/exception.dart' ;
13
+ import 'src/progress.dart' ;
13
14
import 'src/request.dart' ;
14
15
import 'src/response.dart' ;
15
16
import 'src/streamed_request.dart' ;
@@ -22,6 +23,8 @@ export 'src/client.dart' hide zoneClient;
22
23
export 'src/exception.dart' ;
23
24
export 'src/multipart_file.dart' ;
24
25
export 'src/multipart_request.dart' ;
26
+ export 'src/progress.dart'
27
+ hide addTransfer, getProgressTransformer, setLength, setTransferred;
25
28
export 'src/request.dart' ;
26
29
export 'src/response.dart' ;
27
30
export 'src/streamed_request.dart' ;
@@ -44,8 +47,10 @@ Future<Response> head(Uri url, {Map<String, String>? headers}) =>
44
47
/// the same server, you should use a single [Client] for all of those requests.
45
48
///
46
49
/// For more fine-grained control over the request, use [Request] instead.
47
- Future <Response > get (Uri url, {Map <String , String >? headers}) =>
48
- _withClient ((client) => client.get (url, headers: headers));
50
+ Future <Response > get (Uri url,
51
+ {Map <String , String >? headers, HttpProgress ? downloadProgress}) =>
52
+ _withClient ((client) =>
53
+ client.get (url, headers: headers, downloadProgress: downloadProgress));
49
54
50
55
/// Sends an HTTP POST request with the given headers and body to the given URL.
51
56
///
@@ -66,9 +71,17 @@ Future<Response> get(Uri url, {Map<String, String>? headers}) =>
66
71
/// For more fine-grained control over the request, use [Request] or
67
72
/// [StreamedRequest] instead.
68
73
Future <Response > post (Uri url,
69
- {Map <String , String >? headers, Object ? body, Encoding ? encoding}) =>
70
- _withClient ((client) =>
71
- client.post (url, headers: headers, body: body, encoding: encoding));
74
+ {Map <String , String >? headers,
75
+ Object ? body,
76
+ Encoding ? encoding,
77
+ HttpProgress ? downloadProgress,
78
+ HttpProgress ? uploadProgress}) =>
79
+ _withClient ((client) => client.post (url,
80
+ headers: headers,
81
+ body: body,
82
+ encoding: encoding,
83
+ downloadProgress: downloadProgress,
84
+ uploadProgress: uploadProgress));
72
85
73
86
/// Sends an HTTP PUT request with the given headers and body to the given URL.
74
87
///
@@ -89,9 +102,17 @@ Future<Response> post(Uri url,
89
102
/// For more fine-grained control over the request, use [Request] or
90
103
/// [StreamedRequest] instead.
91
104
Future <Response > put (Uri url,
92
- {Map <String , String >? headers, Object ? body, Encoding ? encoding}) =>
93
- _withClient ((client) =>
94
- client.put (url, headers: headers, body: body, encoding: encoding));
105
+ {Map <String , String >? headers,
106
+ Object ? body,
107
+ Encoding ? encoding,
108
+ HttpProgress ? downloadProgress,
109
+ HttpProgress ? uploadProgress}) =>
110
+ _withClient ((client) => client.put (url,
111
+ headers: headers,
112
+ body: body,
113
+ encoding: encoding,
114
+ downloadProgress: downloadProgress,
115
+ uploadProgress: uploadProgress));
95
116
96
117
/// Sends an HTTP PATCH request with the given headers and body to the given
97
118
/// URL.
@@ -113,9 +134,17 @@ Future<Response> put(Uri url,
113
134
/// For more fine-grained control over the request, use [Request] or
114
135
/// [StreamedRequest] instead.
115
136
Future <Response > patch (Uri url,
116
- {Map <String , String >? headers, Object ? body, Encoding ? encoding}) =>
117
- _withClient ((client) =>
118
- client.patch (url, headers: headers, body: body, encoding: encoding));
137
+ {Map <String , String >? headers,
138
+ Object ? body,
139
+ Encoding ? encoding,
140
+ HttpProgress ? downloadProgress,
141
+ HttpProgress ? uploadProgress}) =>
142
+ _withClient ((client) => client.patch (url,
143
+ headers: headers,
144
+ body: body,
145
+ encoding: encoding,
146
+ downloadProgress: downloadProgress,
147
+ uploadProgress: uploadProgress));
119
148
120
149
/// Sends an HTTP DELETE request with the given headers to the given URL.
121
150
///
@@ -125,9 +154,17 @@ Future<Response> patch(Uri url,
125
154
///
126
155
/// For more fine-grained control over the request, use [Request] instead.
127
156
Future <Response > delete (Uri url,
128
- {Map <String , String >? headers, Object ? body, Encoding ? encoding}) =>
129
- _withClient ((client) =>
130
- client.delete (url, headers: headers, body: body, encoding: encoding));
157
+ {Map <String , String >? headers,
158
+ Object ? body,
159
+ Encoding ? encoding,
160
+ HttpProgress ? downloadProgress,
161
+ HttpProgress ? uploadProgress}) =>
162
+ _withClient ((client) => client.delete (url,
163
+ headers: headers,
164
+ body: body,
165
+ encoding: encoding,
166
+ downloadProgress: downloadProgress,
167
+ uploadProgress: uploadProgress));
131
168
132
169
/// Sends an HTTP GET request with the given headers to the given URL and
133
170
/// returns a Future that completes to the body of the response as a [String] .
@@ -141,8 +178,10 @@ Future<Response> delete(Uri url,
141
178
///
142
179
/// For more fine-grained control over the request and response, use [Request]
143
180
/// instead.
144
- Future <String > read (Uri url, {Map <String , String >? headers}) =>
145
- _withClient ((client) => client.read (url, headers: headers));
181
+ Future <String > read (Uri url,
182
+ {Map <String , String >? headers, HttpProgress ? downloadProgress}) =>
183
+ _withClient ((client) =>
184
+ client.read (url, headers: headers, downloadProgress: downloadProgress));
146
185
147
186
/// Sends an HTTP GET request with the given headers to the given URL and
148
187
/// returns a Future that completes to the body of the response as a list of
@@ -157,8 +196,10 @@ Future<String> read(Uri url, {Map<String, String>? headers}) =>
157
196
///
158
197
/// For more fine-grained control over the request and response, use [Request]
159
198
/// instead.
160
- Future <Uint8List > readBytes (Uri url, {Map <String , String >? headers}) =>
161
- _withClient ((client) => client.readBytes (url, headers: headers));
199
+ Future <Uint8List > readBytes (Uri url,
200
+ {Map <String , String >? headers, HttpProgress ? downloadProgress}) =>
201
+ _withClient ((client) => client.readBytes (url,
202
+ headers: headers, downloadProgress: downloadProgress));
162
203
163
204
Future <T > _withClient <T >(Future <T > Function (Client ) fn) async {
164
205
var client = Client ();
0 commit comments