Skip to content

Inefficient Http Client Usage #4

@Yortw

Description

@Yortw

KloutSharp is generally great, however I believe there is some inefficient usage of System.Net.HttpClient. Issues include;

  • Cannot inject an instance of HttpClient (or factory), so cannot apply modifying libaries such as https://github.com/paulcbetts/ModernHttpClient or https://github.com/paulcbetts/Fusillade
  • A new HttpClient instance is created for each call. HttpClient is designed to be re-used, with an internal connection pool (https://msdn.microsoft.com/en-us/library/system.net.http.httpclient(v=vs.110).aspx) being maintained to improve performance. Creating a new client each time defeats the connection pooling.
  • HttpClient instances are not disposed, therefore potentially, temporarily, leaking the pooled connections until garbage collection.
  • GZip compression is not enabled by default on platforms that support it.
  • The library does not use ConfigureAwait(false) on async calls, even though it does not appear to require any sort of thread affinity within the library. This adds a little overhead to each async call.

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