Skip to content
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

More extensibility friendly DefaultHttpMessageInvokerFactory #136

Closed
ArturDorochowicz opened this issue Sep 21, 2022 · 1 comment · Fixed by #141
Closed

More extensibility friendly DefaultHttpMessageInvokerFactory #136

ArturDorochowicz opened this issue Sep 21, 2022 · 1 comment · Fixed by #141

Comments

@ArturDorochowicz
Copy link
Contributor

I'd like to suggest extracting the handler creation here to a separate virtual method:

var socketsHandler = new SocketsHttpHandler
{
UseProxy = false,
AllowAutoRedirect = false,
AutomaticDecompression = DecompressionMethods.None,
UseCookies = false
};

Something like:

protected virtual HttpMessageHandler CreateHandler(string localPath)
{
   return new SocketsHttpHandler { /* ... */ };
}

This will allow derived classes to wrap the base handler in additional DelegatingHandler(s). For instance:

protected override HttpMessageHandler CreateHandler(string localPath) 
{
   var handler = base.CreateHandler(localPath);
   var wrapper = new MyDelegatingHandler { InnerHandler = handler };
   return wrapper;
}

Currently if we just want to wrap the handler, we have to copy the code creating the SocketsHttpHandler from DefaultHttpMessageInvokerFactory.CreateClient.

@leastprivilege
Copy link
Member

Sounds reasonable, do you want to propose a PR?

ArturDorochowicz added a commit to ArturDorochowicz/BFF that referenced this issue Sep 27, 2022
Creating of the `HttpMessageHandler` is extracted to a virtual protected method.

Closes DuendeSoftware#136
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants