Skip to content

SAIF.NetCore.HttpClients operations and processes

This page is the operation catalog and cross-operation hub for SAIF.NetCore.HttpClients. Each operation's detailed, step-by-step logic lives in its own page under operations/.

Operation catalog

Operation Intent Trigger Inputs Outputs Rules
Initialize client Configure the base URL and caller identity an HttpJsonClient instance uses for every request A consumer constructs or configures a resolved HttpJsonClient before issuing a request Base URL, ClientInfo (machine name, application ID, user name), optional timeout override An initialized HttpJsonClient ready to accept requests, or a deferred ClientNotInitializedException on first use BR-HTTP-01, BR-HTTP-02, BR-HTTP-03, BR-HTTP-06
Configure authentication Attach bearer, Basic, or NTLM credentials that subsequent requests send to the target endpoint A consumer calls BearerToken, SetBasicAuthentication, or SetNtlmAuthentication before issuing requests Bearer token string, Basic username/password, or NTLM username/password (or none, for current identity) An HttpJsonClient instance configured to attach the selected credential on outgoing requests BR-HTTP-08, BR-HTTP-09, BR-HTTP-10, BR-HTTP-16
Configure options Replace the retry, header-persistence, and serializer behavior used for subsequent requests A consumer calls SetOptions(HttpClientOptions) An HttpClientOptions instance (retry delay, retry status codes, header persistence flag, serializer) An HttpJsonClient instance with updated request-building and retry behavior BR-HTTP-04, BR-HTTP-07, BR-HTTP-11
Execute request Build, authenticate, execute, and retry an outbound JSON HTTP request for one of the five supported verbs A consumer calls Delete/Get/Patch/Post/Put or an async equivalent HTTP verb, resource path, optional JSON request body An IHttpRequestResult describing status, content, headers, response date, and any error information BR-HTTP-01, BR-HTTP-04, BR-HTTP-05, BR-HTTP-06, BR-HTTP-07, BR-HTTP-08, BR-HTTP-11, BR-HTTP-12, BR-HTTP-13, BR-HTTP-14, BR-HTTP-15, BR-HTTP-17, BR-HTTP-21
Consume result Convert IHttpRequestResult content and headers into strongly typed values A consumer calls GetResult<T>, GetContent<T>, or GetHeaderValue<T> on a returned result An IHttpRequestResult and a target type T A converted T value (or default(T) for GetResult<T> on failure) BR-HTTP-18, BR-HTTP-19, BR-HTTP-20

Process flow diagram

The following diagram visualizes the primary operational flow across operations, from client initialization through result consumption.

flowchart TD
    Start([Consumer resolves HttpJsonClient]) --> Init["Initialize client<br>(base URL, ClientInfo)"]
    Init --> Auth["Configure authentication<br>(bearer / basic / NTLM)"]
    Auth --> Opts["Configure options<br>(retry, persistence, serializer)"]
    Opts --> Exec["Execute request<br>(verb method call)"]
    Exec --> Valid{"Initialized?"}
    Valid -->|No| Err([ClientNotInitializedException])
    Valid -->|Yes| Retry{"Retryable status<br>and retries remain?"}
    Retry -->|Yes| Exec
    Retry -->|No| Result["Consume result<br>(GetResult/GetContent/GetHeaderValue)"]
    Result --> End([Typed value returned to consumer])

Database interactions

This library has no database interactions; no operation reads from or writes to a database.

Failure and edge-case behavior

  • A verb method called before both ClientInfo and the base URL are set throws ClientNotInitializedException without attempting a network call (BR-HTTP-01).
  • A retryable response status (default 401, 502, 503) is retried up to 3 additional times with a blocking delay between attempts (BR-HTTP-04, BR-HTTP-05).
  • With default options, custom headers (including a Basic Authorization header) are dropped on retry attempts, so a 401 retry cannot succeed when Basic auth is the only credential in use (BR-HTTP-07).
  • CreateRequestResult contains defensive handling that normalizes a null RestSharp response into an unsuccessful result rather than surfacing a null-reference condition, but ExecuteRestCall reads response.StatusCode immediately after executing the request and before any null check, so a null response currently throws NullReferenceException there instead of reaching that defensive handling (BR-HTTP-13).
  • Calling any generic *Async<T> overload is a compile-time error (BR-HTTP-21).

Sources

  • src/SAIF.NetCore.HttpClients/SAIF.NetCore.HttpClients/SAIF.NetCore.HttpClients/HttpJsonClient/HttpJsonClient.cs
  • src/SAIF.NetCore.HttpClients/SAIF.NetCore.HttpClients/SAIF.NetCore.HttpClients/HttpJsonClient/HttpRequestResult.cs
  • src/SAIF.NetCore.HttpClients/SAIF.NetCore.HttpClients/SAIF.NetCore.HttpClients/HttpJsonClient/HttpJsonClientExtensions.cs
  • src/SAIF.NetCore.HttpClients/SAIF.NetCore.HttpClients/SAIF.NetCore.HttpClients/ClientInfo.cs