Skip to content

Make ProxyHttpClientFactory public and extensible - #869

Merged
Tratcher merged 1 commit into
mainfrom
tratcher/clientfactory
Apr 12, 2021
Merged

Tratcher merged 1 commit into
mainfrom
tratcher/clientfactory

Conversation

@Tratcher

@Tratcher Tratcher commented Mar 24, 2021 •

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

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
Copy Markdown
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 force-pushed the tratcher/clientfactory branch from 55938b4 to c842d03 Compare April 2, 2021 19:31
@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

@alnikola alnikola left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

.LoadFromMemory(routes, clusters)
.ConfigureClient((context, handler) =>
{
handler.Expect100ContinueTimeout = TimeSpan.FromMilliseconds(300);

Copy link
Copy Markdown
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
Copy Markdown
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