diff --git a/sdk/lib/_http/http.dart b/sdk/lib/_http/http.dart index 84cfbdf05d9..b63102a81af 100644 --- a/sdk/lib/_http/http.dart +++ b/sdk/lib/_http/http.dart @@ -1199,7 +1199,7 @@ abstract class HttpResponse implements IOSink { /// If a body is present, it must be read. Otherwise, it leads to resource /// leaks. Consider using [HttpClientResponse.drain] if the body is unused. /// -/// ```dart +/// ```dart import:convert /// var client = HttpClient(); /// try { /// HttpClientRequest request = await client.get('localhost', 80, '/file.txt'); @@ -1673,7 +1673,8 @@ abstract class HttpClient { /// encoding used is determined from the "charset" parameter of /// the "Content-Type" header. /// -/// ```dart +/// ```dart import:convert +/// var client = HttpClient(); /// HttpClientRequest request = await client.get('localhost', 80, '/file.txt'); /// request.headers.contentType = /// ContentType('application', 'json', charset: 'utf-8'); @@ -1683,6 +1684,7 @@ abstract class HttpClient { /// If no charset is provided the default of ISO-8859-1 (Latin 1) is used. /// /// ```dart +/// var client = HttpClient(); /// HttpClientRequest request = await client.get('localhost', 80, '/file.txt'); /// request.headers.add(HttpHeaders.contentTypeHeader, "text/plain"); /// request.write('blåbærgrød'); // Strings written will be ISO-8859-1 encoded @@ -1783,8 +1785,9 @@ abstract class HttpClientRequest implements IOSink { /// the request has been aborted /// /// ```dart import:async - /// HttpClientRequest request = ... - /// request.write(); + /// var client = HttpClient(); + /// HttpClientRequest request = await client.get('localhost', 80, '/file.txt'); + /// request.write('request content'); /// Timer(Duration(seconds: 1), () { /// request.abort(); /// }); @@ -1804,7 +1807,7 @@ abstract class HttpClientRequest implements IOSink { /// server. Use [Stream] methods like [`transform`][Stream.transform] and /// [`join`][Stream.join] to access the data. /// -/// ```dart +/// ```dart import:convert /// var client = HttpClient(); /// try { /// HttpClientRequest request = await client.get('localhost', 80, '/file.txt'); diff --git a/sdk/lib/_http/overrides.dart b/sdk/lib/_http/overrides.dart index db464f8e554..021a978ef07 100644 --- a/sdk/lib/_http/overrides.dart +++ b/sdk/lib/_http/overrides.dart @@ -13,20 +13,22 @@ const _asyncRunZoned = runZoned; /// that construct a mock implementation. The implementation in this base class /// defaults to the actual [HttpClient] implementation. For example: /// -/// ```dart +/// ```dart import:io +/// // An implementation of the HttpClient interface /// class MyHttpClient implements HttpClient { -/// ... -/// // An implementation of the HttpClient interface -/// ... +/// MyHttpClient(SecurityContext? c); +/// +/// @override +/// noSuchMethod(Invocation invocation) { +/// // your implementation here +/// } /// } /// -/// main() { +/// void main() { /// HttpOverrides.runZoned(() { -/// ... /// // Operations will use MyHttpClient instead of the real HttpClient /// // implementation whenever HttpClient is used. -/// ... -/// }, createHttpClient: (SecurityContext c) => MyHttpClient(c)); +/// }, createHttpClient: (SecurityContext? c) => MyHttpClient(c)); /// } /// ``` abstract class HttpOverrides { diff --git a/tools/bots/test_matrix.json b/tools/bots/test_matrix.json index 448629ca721..5a1286dfc14 100644 --- a/tools/bots/test_matrix.json +++ b/tools/bots/test_matrix.json @@ -3474,6 +3474,7 @@ "script": "out/ReleaseX64/dart-sdk/bin/dart", "arguments": [ "tools/verify_docs/bin/verify_docs.dart", + "sdk/lib/_http", "sdk/lib/_internal", "sdk/lib/cli", "sdk/lib/convert",