Skip to content

New HttpClients are created-per request #25

@aspriddell

Description

@aspriddell

HttpClients are designed to be reused, and as such shouldn't be disposed of:

https://github.com/abuZayed15/check-link/blob/d57972cb7c91e0cfcef709e62cb600e5112fb832/CheckLinkCLI2/CheckLinkCLI2/WebLinkChecker.cs#L67-L70 https://github.com/abuZayed15/check-link/blob/d57972cb7c91e0cfcef709e62cb600e5112fb832/CheckLinkCLI2/CheckLinkCLI2/WebLinkChecker.cs#L161-L164

I think it would be a good idea to create a static HttpClient and reuse it, without disposing of it.
You also might want to consider using something like DragonFruit.Common, which simplifies all of this into classes where the requests are generated and the client disposal/management are done for you. (should you want to use this I can explain how to use it)

Also worth noting you need to dispose of the HttpResponseMessages:
https://github.com/abuZayed15/check-link/blob/d57972cb7c91e0cfcef709e62cb600e5112fb832/CheckLinkCLI2/CheckLinkCLI2/WebLinkChecker.cs#L76 https://github.com/abuZayed15/check-link/blob/d57972cb7c91e0cfcef709e62cb600e5112fb832/CheckLinkCLI2/CheckLinkCLI2/WebLinkChecker.cs#L166

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions