Skip to content

Commit 70dc619

Browse files
authored
HttpClient: remove redundant and outdated runtime config switch information (#5028)
Removes redundant and outdated information about runtime configuration options for HttpClient, referencing the options docs page instead. Related PR updating the options docs: dotnet/docs#21197
1 parent 809f2c0 commit 70dc619

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

xml/System.Net.Http/HttpClient.xml

+3-24
Original file line numberDiff line numberDiff line change
@@ -112,37 +112,16 @@ On each platform, <xref:System.Net.Http.HttpClient> tries to use the best availa
112112
Users can also configure a specific transport for <xref:System.Net.Http.HttpClient> by invoking the <xref:System.Net.Http.HttpClient.%23ctor*> constructor that takes an <xref:System.Net.Http.HttpMessageHandler>.
113113
114114
### HttpClient and .NET Core
115-
116115
Starting with .NET Core 2.1, the <xref:System.Net.Http.SocketsHttpHandler?displayProperty=nameWithType> class instead of `HttpClientHandler` provides the implementation used by higher-level HTTP networking classes such as `HttpClient`. The use of <xref:System.Net.Http.SocketsHttpHandler> offers a number of advantages:
117-
118116
- A significant performance improvement when compared with the previous implementation.
119-
120117
- The elimination of platform dependencies, which simplifies deployment and servicing. For example, `libcurl` is no longer a dependency on .NET Core for macOS and .NET Core for Linux.
121-
122118
- Consistent behavior across all .NET platforms.
123119
124-
If this change is undesirable, you can configure your application to use the older <xref:System.Net.Http.HttpClientHandler?displayProperty=nameWithType> instead in a number of ways:
120+
If this change is undesirable, on Windows you can still use <xref:System.Net.Http.WinHttpHandler> by referencing it's [NuGet package](https://www.nuget.org/packages/System.Net.Http.WinHttpHandler/) and passing it to [`HttpClient`'s constructor`](xref:System.Net.Http.HttpClient.%23ctor(System.Net.Http.HttpMessageHandler)) manually.
125121
126-
- By calling the <xref:System.AppContext.SetSwitch%2A?displayProperty=nameWithType> method as follows:
122+
### Configure behavior using run-time configuration options
127123
128-
```csharp
129-
AppContext.SetSwitch("System.Net.Http.UseSocketsHttpHandler", false);
130-
```
131-
132-
```vb
133-
AppContext.SetSwitch("System.Net.Http.UseSocketsHttpHandler", False)
134-
```
135-
- By defining the `System.Net.Http.UseSocketsHttpHandler` switch in the *.netcore.runtimeconfig.json* configuration file:
136-
137-
```json
138-
"runtimeOptions": {
139-
"configProperties": {
140-
"System.Net.Http.UseSocketsHttpHandler": false
141-
}
142-
}
143-
```
144-
145-
- By defining an environment variable named `DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER` and setting it to either `false` or 0.
124+
Certain aspects of <xref:System.Net.Http.HttpClient>'s behavior are customizable through [Run-time configuration options](/dotnet/core/run-time-config/networking). However, the behavior of these switches differs through .NET versions. For example, in .NET Core 2.1 - 3.1, you can configure whether <xref:System.Net.Http.SocketsHttpHandler> is used by default, but that option is no longer available starting in .NET 5.0.
146125
147126
## Examples
148127
[!code-csharp[System.Net.Http.HttpClient#1](~/samples/snippets/csharp/VS_Snippets_Misc/system.net.http.httpclient/cs/source.cs#1)]

0 commit comments

Comments
 (0)