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

Make ProxyHttpClientFactory public and extensible #869

Merged
merged 1 commit into from
Apr 12, 2021

Conversation

Tratcher
Copy link
Member

@Tratcher Tratcher commented Mar 24, 2021

Fixes #805 Make ProxyHttpClientFactory public and extensible
Fixes #843 (@berhir) Enable adding HttpMessageHandler middleware (e.g. DelegatingHandler)
Contributes to #801 Allow using ProxyHttpClientFactory for direct IHttpProxy scenarios

ProxyHttpClientFactory is now public so people can:
A) Create it directly when using IHttpProxy
B) Derive from it to customize the SocketHttpHandler settings without completely re-implementing IProxyHttpClientFactory
C) Derive from it to enable wrapping SocketHttpHandler with DelegatingHandler middleware.

There's also a new extension for simple scenarios:

            services.AddReverseProxy()
                .ConfigureClient((context, handler) =>
                {
                    handler.Expect100ContinueTimeout = TimeSpan.FromMilliseconds(300);
                })


Log.ProxyClientCreated(_logger, context.ClusterId);

return new HttpMessageInvoker(middleware, disposeHandler: true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this HttpMessageInvoker ever get disposed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, there's no way of telling when it's no longer in use, except that it will get GC'd.

@Tratcher Tratcher added this to the YARP 1.0.0-preview11 milestone Apr 2, 2021
@Tratcher Tratcher marked this pull request as ready for review April 2, 2021 20:15
Copy link
Contributor

@alnikola alnikola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -52,6 +52,10 @@ public void ConfigureServices(IServiceCollection services)

services.AddReverseProxy()
.LoadFromMemory(routes, clusters)
.ConfigureClient((context, handler) =>
{
handler.Expect100ContinueTimeout = TimeSpan.FromMilliseconds(300);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expect100ContinueTimeout or ConfigureClient?

  • ConfigureClient this lets users change basic settings without implementing a new class.
  • Expect100ContinueTimeout is only used here has an example.

@Tratcher Tratcher merged commit 10867bd into main Apr 12, 2021
@Tratcher Tratcher deleted the tratcher/clientfactory branch April 12, 2021 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sample/Docs for using a DelegatingHandler Make ProxyHttpClientFactory public and extensible
4 participants