Skip to content

Commit

Permalink
Use consistent handler defaults in docs and samples (#2451)
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaZupan committed Apr 2, 2024
1 parent fc9929f commit 83c3607
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docs/docfx/articles/direct-forwarding.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ builder.Services.AddHttpForwarder();
var app = builder.Build();

// Configure our own HttpMessageInvoker for outbound calls for proxy operations
var httpClient = new HttpMessageInvoker(new SocketsHttpHandler()
var httpClient = new HttpMessageInvoker(new SocketsHttpHandler
{
UseProxy = false,
AllowAutoRedirect = false,
AutomaticDecompression = DecompressionMethods.None,
UseCookies = false,
EnableMultipleHttp2Connections = true,
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current),
ConnectTimeout = TimeSpan.FromSeconds(15),
});
Expand Down
5 changes: 4 additions & 1 deletion docs/docfx/articles/http-client-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ new SocketsHttpHandler
AllowAutoRedirect = false,
AutomaticDecompression = DecompressionMethods.None,
UseCookies = false,
EnableMultipleHttp2Connections = true,
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current),
ConnectTimeout = TimeSpan.FromSeconds(15),
};
Expand All @@ -227,7 +228,9 @@ public class CustomForwarderHttpClientFactory : IForwarderHttpClientFactory
AllowAutoRedirect = false,
AutomaticDecompression = DecompressionMethods.None,
UseCookies = false,
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current)
EnableMultipleHttp2Connections = true,
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current),
ConnectTimeout = TimeSpan.FromSeconds(15),
};

return new HttpMessageInvoker(handler, disposeHandler: true);
Expand Down
3 changes: 2 additions & 1 deletion samples/ReverseProxy.Direct.Sample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
var app = builder.Build();

// Configure our own HttpMessageInvoker for outbound calls for proxy operations
var httpClient = new HttpMessageInvoker(new SocketsHttpHandler()
var httpClient = new HttpMessageInvoker(new SocketsHttpHandler
{
UseProxy = false,
AllowAutoRedirect = false,
AutomaticDecompression = DecompressionMethods.None,
UseCookies = false,
EnableMultipleHttp2Connections = true,
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current),
ConnectTimeout = TimeSpan.FromSeconds(15),
});
Expand Down
1 change: 1 addition & 0 deletions src/ReverseProxy/Forwarder/ForwarderHttpClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public HttpMessageInvoker CreateClient(ForwarderHttpClientContext context)
AllowAutoRedirect = false,
AutomaticDecompression = DecompressionMethods.None,
UseCookies = false,
EnableMultipleHttp2Connections = true,
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current),
ConnectTimeout = TimeSpan.FromSeconds(15),

Expand Down
3 changes: 2 additions & 1 deletion testassets/ReverseProxy.Direct/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@

var app = builder.Build();

var httpClient = new HttpMessageInvoker(new SocketsHttpHandler()
var httpClient = new HttpMessageInvoker(new SocketsHttpHandler
{
UseProxy = false,
AllowAutoRedirect = false,
AutomaticDecompression = DecompressionMethods.None,
UseCookies = false,
EnableMultipleHttp2Connections = true,
ActivityHeadersPropagator = new ReverseProxyPropagator(DistributedContextPropagator.Current),
ConnectTimeout = TimeSpan.FromSeconds(15),
});
Expand Down

0 comments on commit 83c3607

Please sign in to comment.