Skip to content

Commit db7f165

Browse files
authored
Provide an example of configuring IOClient with an HttpClient. (#1074)
1 parent cd748b6 commit db7f165

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pkgs/http/lib/src/io_client.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ class IOClient extends BaseClient {
7272
/// The underlying `dart:io` HTTP client.
7373
HttpClient? _inner;
7474

75+
/// Create a new `dart:io`-based HTTP [Client].
76+
///
77+
/// If [inner] is provided then it can be used to provide configuration
78+
/// options for the client.
79+
///
80+
/// For example:
81+
/// ```dart
82+
/// final httpClient = HttpClient()
83+
/// ..userAgent = 'Book Agent'
84+
/// ..idleTimeout = const Duration(seconds: 5);
85+
/// final client = IOClient(httpClient);
86+
/// ```
7587
IOClient([HttpClient? inner]) : _inner = inner ?? HttpClient();
7688

7789
/// Sends an HTTP request and asynchronously returns the response.

0 commit comments

Comments
 (0)