Skip to content

Refactor httpClient to be reused #208

Description

@jhorn70

I have been trying to troubleshoot an issue with task cancellation and stumbled on the below.

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

Looks like the best practice is to re-use HttpClient across multiple requests.

In looking at the code, I would probably implement the RequestHandler as static inside AbstractClient. It can be reused for all requests for the lifetime of an instance of OnlineClient. Inside that I would implement HttpClient as static in the same way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions