Skip to content

Allow control of HttpMessageHandler lifetime. #232

Open
davidathompson wants to merge 1 commit intointacct:masterfrom
davidathompson:master
Open

Allow control of HttpMessageHandler lifetime. #232
davidathompson wants to merge 1 commit intointacct:masterfrom
davidathompson:master

Conversation

@davidathompson
Copy link
Copy Markdown

The library currently creates a new HttpMessageHandler for each request. If you open up resource monitor, or use netstat you will start to see hundreds (or thousands) of open tcp connections.

Background for this:

https://www.aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/

https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?redirectedfrom=MSDN&view=net-6.0#Remarks

This pull request changes the datatype and name in the ClientConfig to HttpMessageHandler. This allows a user who wishes to control lifetime of the handler to supply their own instance.

Unit tests were updated to use the new generic name, with an obsolete property which points back to it to avoid breaking existing users.

…erty called MockHandler to ensure any direct use of the name "MockHandler" will still work.

Because MockHandler ultimately derives from HttpMessageHandler, all unit tests can now populate this and still work as they have been.

This change allows a library user to control the life cycle of HttpMessageHandler, while still hooking into the logging provided.
Copy link
Copy Markdown

@jhorn70 jhorn70 left a comment

Choose a reason for hiding this comment

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

All this looks solid

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.

2 participants