Skip to content

Following best-practices for HttpClient #1918

Closed
@samcic

Description

In the latest version of this library, creating a StripeClient with the minimal constructor creates a new SystemNetHttpClient, which in turn creates a new HttpClient.

In some cases, multiple StripeClients need to be created in an application (e.g. when dealing with multiple Stripe accounts, each with a different API key).

The "best practices" for HttpClient instances are mentioned by Microsoft as follows:

HttpClient is intended to be instantiated once and reused throughout the life of an application.

My questions:

  • Why isn't SystemNetHttpClient using a static, application-wide HttpClient instance?
  • When passing a custom SystemNetHttpClient instance to StripeClient, is there any danger in using a static, application-wide HttpClient instance?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

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