Table of Contents

Client

The framework Client wraps outbound HTTP requests and is designed for reuse, resilience, and simplified integration code.

Features

  • HTTP verbs: GET, POST, PUT, DELETE, HEAD, OPTIONS, and related requests
  • Connection reuse: underlying HttpClient instances are reused based on host and connection configuration
  • Retry behavior: retries are applied according to the request type and configured policy
  • Fluent usage: call directly from a string URL or a typed client instance
  • Resilience: supports the framework’s default timeout and error-handling behavior

Behavior

The framework caches HttpClient instances per host, port, timeout, scheme, SSL, and decompression configuration so requests can reuse a healthy connection instead of creating a new client every time.

Retry policy disabled (default):

  • Always retries once on 502, 504 for GET, POST and file requests
  • Always retries once if remote host forcibly closes the connection
  • These base retries cannot be disabled

Retry policy enabled:

  • All of the above, plus retries on 401, 404, 500 for GET/POST and file requests
  • Up to two retries if response is null (timeout)
  • 666ms delay between retries

useRetryPolicy: false (default)

  • Retries once on 502, 504 (GET, POST, file requests)

useRetryPolicy: true

  • Same as false, plus:
    • Retries one extra time on 502, 504 (GET, POST)
    • Retries twice if response is null (timeout/no response)
    • Retries once on:
      • 401 for GET, POST
      • 404 for GET
      • 500 for GET, POST
      • 404, 500, 502, 504 for file requests
      • 404, 502, 504 for OPTION, PATCH, HEAD, CONNECT, TRACE**
var client = new Client();
var response = client.Get<string>("https://api.example.com/data");

The same pattern also works via URL-based extensions:

var response = "https://api.example.com/data".GetRequest<string>();

Caveats

  • DELETE and PUT requests are not retried.
  • throwOnUnsuccessful defaults to false, so some failures are logged rather than thrown.
  • ClientCertificate must include a private key or an exception is raised when used.
  • Retry behavior is intentionally conservative and depends on the framework’s configuration.
Tip

Inherit from Client to build typed integration clients that share a base URL, headers, and authentication logic across your application.

AppSettings

View all appsettings here