StormByte-Network 4.0.0
C++26 networking module of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Network::HTTP::Client Class Referencefinal

Synchronous single-request-per-connection client. More...

#include <StormByte/network/http/client.hxx>

Public Member Functions

 Client ()
 Allocate a managed resolver inside Network.
 Client (const Client &other)=delete
 Copying a resolver owner is disabled.
 Client (Client &&other) noexcept
 Transfer resolver and immutable TLS policy; moved-from clients can be reassigned but Execute returns InvalidOptions.
 ~Client () noexcept
 Join retained DNS work and release provider-owned policy.
Client & operator= (const Client &other)=delete
 Copy assignment is disabled.
Client & operator= (Client &&other) noexcept
 Transfer resolver and policy, joining this client's DNS work.
bool ConfigureTLS (const Crypto::TLS::ClientConfiguration &configuration, bool refresh_validation_time=true) noexcept
 Deep-copy custom trust, identity, revocation and mTLS inputs.
bool ConfigureTLS (const Crypto::TLS::ClientConfiguration &configuration, Safe::String &detail, bool refresh_validation_time=true)
 Configure TLS with an owned explanation on failure.
Expected< Response, Error > Execute (const Request &request, const Options &options={})
 Execute one bounded request, closing its connection on all exits.
Expected< Response, Error > Execute (const Request &request, const Options &options, Safe::String &detail)
 Execute with an owned TLS failure explanation.

Detailed Description

Synchronous single-request-per-connection client.

No pooling, redirects, decompression, retries, proxy or server. Serialize Execute, ConfigureTLS, moves and destruction externally. Its managed resolver retains at most one DNS worker after timeout; subsequent calls may return ResolverBusy. Destruction joins that worker and can wait for the OS resolver independently of request deadlines. Network, Crypto, Base and logger providers must stay loaded until release.

Constructor & Destructor Documentation

◆ Client() [1/3]

StormByte::Network::HTTP::Client::Client ( )

Allocate a managed resolver inside Network.

Exceptions
StormByte::Safe::AllocationErrorResolver ownership cannot be allocated.

◆ Client() [2/3]

StormByte::Network::HTTP::Client::Client ( const Client & other)
delete

Copying a resolver owner is disabled.

Parameters
otherSource client.

◆ Client() [3/3]

StormByte::Network::HTTP::Client::Client ( Client && other)
noexcept

Transfer resolver and immutable TLS policy; moved-from clients can be reassigned but Execute returns InvalidOptions.

Parameters
otherSource client.

◆ ~Client()

StormByte::Network::HTTP::Client::~Client ( )
noexcept

Join retained DNS work and release provider-owned policy.

Member Function Documentation

◆ ConfigureTLS() [1/2]

bool StormByte::Network::HTTP::Client::ConfigureTLS ( const Crypto::TLS::ClientConfiguration & configuration,
bool refresh_validation_time = true )
noexcept

Deep-copy custom trust, identity, revocation and mTLS inputs.

ALPN is controlled by HTTP Options, not the supplied alpn_wire. Failed configuration leaves the prior policy unchanged.

Parameters
configurationSynchronously borrowed Crypto inputs.
refresh_validation_timeDefault true validates at each new session; false explicitly opts into the supplied fixed validation time.
Returns
Whether the copied TLS configuration is valid.

◆ ConfigureTLS() [2/2]

bool StormByte::Network::HTTP::Client::ConfigureTLS ( const Crypto::TLS::ClientConfiguration & configuration,
Safe::String & detail,
bool refresh_validation_time = true )

Configure TLS with an owned explanation on failure.

Parameters
configurationBorrowed Crypto inputs.
detailOutput cleared on entry; copied category or allocation explanation on failure.
refresh_validation_timeRefresh validation time per session.
Returns
Whether configuration succeeded; prior policy survives failure.
Exceptions
StormByte::Safe::AllocationErrorExplanation storage cannot be allocated.

◆ Execute() [1/2]

Expected< Response, Error > StormByte::Network::HTTP::Client::Execute ( const Request & request,
const Options & options,
Safe::String & detail )

Execute with an owned TLS failure explanation.

Parameters
requestBorrowed request.
optionsTotal deadline, protocol and buffer bounds.
detailOutput cleared on entry; populated for TLS failures and unnotified TLS EOF.
Returns
The same response or typed error as the existing overload.
Exceptions
StormByte::Safe::AllocationErrorResult or explanation storage cannot be allocated.

The output survives session destruction. Non-TLS errors leave it empty. No class layout or error-enumeration changes are required.

◆ Execute() [2/2]

Expected< Response, Error > StormByte::Network::HTTP::Client::Execute ( const Request & request,
const Options & options = {} )

Execute one bounded request, closing its connection on all exits.

Default HTTPS verifies URL identity with bundled Crypto roots. Explicit identity configuration instead verifies that configured identity.

Parameters
requestSynchronously borrowed immutable request.
optionsTotal deadline, protocol and buffer bounds.
Returns
Final response or explicit failure; never partial success. With a Receiver, failure can follow bytes already delivered to it.
Exceptions
StormByte::Safe::AllocationErrorError storage cannot be allocated.

◆ operator=() [1/2]

Client & StormByte::Network::HTTP::Client::operator= ( Client && other)
noexcept

Transfer resolver and policy, joining this client's DNS work.

Parameters
otherSource client.
Returns
This client.

◆ operator=() [2/2]

Client & StormByte::Network::HTTP::Client::operator= ( const Client & other)
delete

Copy assignment is disabled.

Parameters
otherSource client.
Returns
No value; deleted.

The documentation for this class was generated from the following file: