Skip to content

Configure HTTP client options

Initialize an HttpClientOptions instance with its defaults and apply optional fluent overrides. This operation is triggered when a consumer creates options and passes them to IHttpJsonClient.SetOptions.

Field Value
Operation ID OP-03
Trigger A consumer creates options and passes them to IHttpJsonClient.SetOptions.
Inputs None for initialization; optional fluent-method arguments (option, nothing for UseNewtonsoftJson).
Outputs A configured HttpClientOptions instance; the fluent methods return this for chaining.
Primary components HttpClientOptions initializer, .PersistHeaders, .UseNewtonsoftJson
Entry point src/SAIF.NetCore.ServiceContracts/SAIF.NetCore.ServiceContracts/SAIF.NetCore.ServiceContracts/HttpClientOptions.cs

Steps

  1. Initialization applies the defaults: PersistHeadersAfterRequest=false, RetryDelayInMs=1000, RetryOnStatusCodes=[401,502,503], Serializer=Default. (BR-006)
  2. Optional: call PersistHeaders(bool option = true) to set PersistHeadersAfterRequest = option and return this. (BR-007)
  3. Optional: call UseNewtonsoftJson() to set Serializer = HttpClientSerializer.NewtonsoftJson and return this. (BR-008)

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start([new HttpClientOptions]) --> Defaults[Apply default values]
    Defaults --> Persist{Call PersistHeaders?}
    Persist -->|Yes| SetPersist[Set PersistHeadersAfterRequest]
    Persist -->|No| Newtonsoft
    SetPersist --> Newtonsoft{Call UseNewtonsoftJson?}
    Newtonsoft -->|Yes| SetSerializer[Set Serializer to NewtonsoftJson]
    Newtonsoft -->|No| End([Options ready for SetOptions])
    SetSerializer --> End

Failure and edge-case behavior

  • No validation failures are possible; every fluent method is a pure property assignment.
  • How the options are interpreted at runtime (retry loop, header clearing) is implemented in SAIF.NetCore.HttpClients, not here*.

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • src/SAIF.NetCore.ServiceContracts/SAIF.NetCore.ServiceContracts/SAIF.NetCore.ServiceContracts/HttpClientOptions.cs