You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've just marked ShopifySharp.Infrastructure.DefaultHttpClientFactory as obsolete in v6.2, and intend to remove it in a future release after sufficient time has passed. Inside ShopifySharp, I've replaced the class with a new InternalHttpClientFactory which, as the name implies, is internal access only.
The issue with the DefaultHttpClientFactory is that it ignores all configuration passed to it and returns a completely unmodified HttpClient:
This is fine for ShopifySharp's own internal usage, it doesn't need or expect the factory to do any kind of configuration. However, if you're like me and decide that ShopifySharp conveniently gives you this nice, public IHttpClientFactory that you can just plug into your Startup.cs file and then forget about, you'll start to run into bugs when other services in your app expect the factory to configure the client but it doesn't.
This method is clearly expecting the factory to call its configuration method so that it can configure the HttpClient with that base address and default authorization header. But since ShopifySharp dutifully ignores the configuration, those defaults are never set and whatever the "FooClient" is used for is going to break.
If you accidentally used ShopifySharp's DefaultHttpClientFactory in your app's DI services like I did, you can replace it with a simple services.AddHttpClient() from Microsoft.Extensions.DependencyInjection
The text was updated successfully, but these errors were encountered:
I've just marked
ShopifySharp.Infrastructure.DefaultHttpClientFactory
as obsolete in v6.2, and intend to remove it in a future release after sufficient time has passed. Inside ShopifySharp, I've replaced the class with a newInternalHttpClientFactory
which, as the name implies, is internal access only.The issue with the
DefaultHttpClientFactory
is that it ignores all configuration passed to it and returns a completely unmodifiedHttpClient
:This is fine for ShopifySharp's own internal usage, it doesn't need or expect the factory to do any kind of configuration. However, if you're like me and decide that ShopifySharp conveniently gives you this nice, public
IHttpClientFactory
that you can just plug into your Startup.cs file and then forget about, you'll start to run into bugs when other services in your app expect the factory to configure the client but it doesn't.Consider the following:
This method is clearly expecting the factory to call its configuration method so that it can configure the
HttpClient
with that base address and default authorization header. But since ShopifySharp dutifully ignores the configuration, those defaults are never set and whatever the "FooClient" is used for is going to break.If you accidentally used ShopifySharp's
DefaultHttpClientFactory
in your app's DI services like I did, you can replace it with a simpleservices.AddHttpClient()
from Microsoft.Extensions.DependencyInjectionThe text was updated successfully, but these errors were encountered: