From 4237af25f6e2321b2b1e268bd48f76b676776488 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Thu, 7 Dec 2023 13:23:58 -0800 Subject: [PATCH] Provide an example of configuring IOClient with an HttpClient. --- pkgs/http/lib/src/io_client.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkgs/http/lib/src/io_client.dart b/pkgs/http/lib/src/io_client.dart index 247cc8cad6..db66b028c4 100644 --- a/pkgs/http/lib/src/io_client.dart +++ b/pkgs/http/lib/src/io_client.dart @@ -72,6 +72,18 @@ class IOClient extends BaseClient { /// The underlying `dart:io` HTTP client. HttpClient? _inner; + /// Create a new `dart:io`-based HTTP [Client]. + /// + /// If [inner] is provided then it can be used to provide configuration + /// options for the client. + /// + /// For example: + /// ```dart + /// final httpClient = HttpClient() + /// ..userAgent = 'Book Agent' + /// ..idleTimeout = const Duration(seconds: 5); + /// final client = IOClient(httpClient); + /// ``` IOClient([HttpClient? inner]) : _inner = inner ?? HttpClient(); /// Sends an HTTP request and asynchronously returns the response.