-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SocketsHttpHandler.ConnectCallback #41949
Labels
api-approved
API was approved in API review, it can be implemented
area-System.Net.Http
blocking-release
Milestone
Comments
Tagging subscribers to this area: @dotnet/ncl |
namespace System.Net.Http
{
public sealed class SocketsHttpConnectionContext
{
public DnsEndPoint DnsEndPoint { get; }
public HttpRequestMessage RequestMessage { get; }
}
public sealed class SocketsHttpHandler : HttpMessageHandler
{
public Func<SocketsHttpConnectionContext, CancellationToken, ValueTask<Stream>>? ConnectCallback { get; set; }
}
} |
Reopening this issue to wait for backport to 5.0 in PR #42075 |
Backport to 5.0 RC2 is merged in PR #42075 |
This was referenced Sep 17, 2020
Closed
This was referenced Sep 17, 2020
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
api-approved
API was approved in API review, it can be implemented
area-System.Net.Http
blocking-release
Background and Motivation
We recently removed System.Net.Connections from 5.0. One feature we lost was the ConnectionFactory property on SocketsHttpHandler, which allowed you to plug in your own transport that SocketsHttpHandler would run over.
This new API provides the same capability to replace the transport without relying on System.Net.Connections. When you set this property, your callback will be invoked whenever SocketsHttpHandler needs to create a new connection. You can use this callback to create the Stream however you want -- e.g. use an in-memory stream, bind to a particular local address, etc.
Proposed API
The DnsEndPoint argument identifies the server we are trying to connect to. The HttpRequestMessage argument allows you to inspect the initial HttpRequestMessage for this connection -- though you should be aware that the connection can be used for many requests, not just this initial one. We expect most users will only need the DnsEndPoint.
The text was updated successfully, but these errors were encountered: