---
title: Configure HTTP client options
summary: Initialize an `HttpClientOptions` instance with its defaults and apply optional fluent overrides.
status: draft
owner: Framework.NCore maintainers
last_reviewed: 2026-10-02
library: SAIF.NetCore.ServiceContracts
reference_type: package
operation_id: OP-03
trigger: A consumer creates options and passes them to `IHttpJsonClient.SetOptions`.
---

# 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](../business-rules.md#br-006-http-client-option-defaults))
2. Optional: call `PersistHeaders(bool option = true)` to set `PersistHeadersAfterRequest = option` and return `this`. ([BR-007](../business-rules.md#br-007-persistheaders-with-no-argument-enables-persistence))
3. Optional: call `UseNewtonsoftJson()` to set `Serializer = HttpClientSerializer.NewtonsoftJson` and return `this`. ([BR-008](../business-rules.md#br-008-usenewtonsoftjson-selects-the-newtonsoft-serializer))

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
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*.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

> **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`
