@@ -15,6 +15,24 @@ import 'response.dart';
15
15
/// A `dart:io` -based HTTP client.
16
16
///
17
17
/// This is the default client when running on the command line.
18
+ ///
19
+ /// You can control the underlying `dart:io` [HttpRequest] by adding values to
20
+ /// [Request.context] :
21
+ ///
22
+ /// * `"http.io.follow_redirects"` is a boolean. If it's `true` (the default)
23
+ /// then the request will automatically follow HTTP redirects. If it's
24
+ /// `false` , the client will need to handle redirects manually. See also
25
+ /// [HttpClientRequest.followRedirects] .
26
+ ///
27
+ /// * `"http.io.max_redirects"` is an integer that specifies the maximum number
28
+ /// of redirects that will be followed if `follow_redirects` is `true` . If the
29
+ /// site redirects more than this, [send] will throw a [ClientException] . It
30
+ /// defaults to `5` . See also [HttpClientRequest.maxRedirects] .
31
+ ///
32
+ /// * `"http.io.persistent_connection"` is a boolean. If it's `true` (the
33
+ /// default) the client will request that the TCP connection be kept alive
34
+ /// after the request completes. See also
35
+ /// [HttpClientRequest.persistentConnection] .
18
36
class IOClient extends BaseClient {
19
37
/// The underlying `dart:io` HTTP client.
20
38
HttpClient _inner;
@@ -28,9 +46,10 @@ class IOClient extends BaseClient {
28
46
var context = request.context;
29
47
30
48
ioRequest
31
- ..followRedirects = context['io.followRedirects' ] ?? true
32
- ..maxRedirects = context['io.maxRedirects' ] ?? 5
33
- ..persistentConnection = context['io.persistentConnection' ] ?? true ;
49
+ ..followRedirects = context['http.io.follow_redirects' ] ?? true
50
+ ..maxRedirects = context['http.io.max_redirects' ] ?? 5
51
+ ..persistentConnection =
52
+ context['http.io.persistent_connection' ] ?? true ;
34
53
request.headers.forEach ((name, value) {
35
54
ioRequest.headers.set (name, value);
36
55
});
0 commit comments