Genbox / SimpleS3

A .NET Core implementation of Amazon's S3 API with focus on simplicity, security and performance
MIT License
48 stars 8 forks source link

Document how to configure HttpClient options #22

Closed LordMike closed 3 years ago

LordMike commented 4 years ago

Such as timeout.

For reference, SimpleS3 (when using HttpClientFactory) uses a client named SimpleS3. It can be configured like such (I need infinite timeouts):

var builder = services.AddSimpleS3Core();
builder.UseHttpClientFactory();

services.AddHttpClient("SimpleS3", client => client.Timeout = Timeout.InfiniteTimeSpan);

... buuut.. there's a simpler way, apparently. The IHttpClientBuilder from UseHttpClientFactory() allows one to configure the client:

IHttpClientBuilder httpClientBuilder = builder
    .UseHttpClientFactory();

httpClientBuilder
    .ConfigureHttpClient(client => client.Timeout = Timeout.InfiniteTimeSpan);
Genbox commented 4 years ago

That's honestly the fault of Microsoft. They attach a lot of extensions to the service collection once you add their dependency. They make it convenient to use their libraries, but it is not a good design and adds confusion.

I'm working on streamlining how you can configure proxy, timeout etc. Documentation comes after.

Genbox commented 3 years ago

The streamlining is finished. Documentation can be found in the SimpleS3.ExamplesAdvanced project.