General Configuration

Since version 3.0 RestClient supports granular configuration of the underline HttpClient via the Config class and it’s Pipeline.

From version 3.3.0 we support configuration of the HttpClient Pipeline using IHttpClientFactory.

General config is just done by setting properties on the Config object.

When directly creating a RestClient instance pass the Config object to the constructor:

var config = new Config
   //HttpClient request timeout
   Timeout = TimeSpan.FromSeconds(10.0), 
   //HttpClient MaxResponseContentBufferSize
   MaxResponseContentBufferSize = 1000, 
   //Whether to use the DefaultJsonHandler which is added to the beginning of Pipeline by default 
   UseDefaultHandlers = false

var restClient = new RestClient("", config);

When using IHttpClientFactory use the ConfigureHttpClient extension method when adding the RestClient to your .NET Core DI container (usually in Startup.cs)

   .HttpClientBuilder.ConfigureHttpClient(client =>
      client.Timeout = TimeSpan.FromMinutes(1);
      client.MaxResponseContentBufferSize = 1000;