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

Borrowed streaming consumer of the final response body. More...

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

Public Member Functions

 Receiver () noexcept=default
 Construct a stateless receiver base.
 Receiver (const Receiver &other) noexcept=default
 Copy the stateless base.
 Receiver (Receiver &&other) noexcept=default
 Move the stateless base.
virtual ~Receiver () noexcept
 Destroy the receiver.
Receiver & operator= (const Receiver &other) noexcept=default
 Copy the stateless base.
Receiver & operator= (Receiver &&other) noexcept=default
 Move the stateless base.
virtual bool Begin (unsigned short status, const Safe::Vector< Header > &headers)=0
 Accept or decline the final response before its body.
virtual bool Write (std::span< const std::byte > bytes)=0
 Consume the next nonempty body chunk.

Detailed Description

Borrowed streaming consumer of the final response body.

When Options::receiver is set, Begin is called once with the final status and fields before any body byte, including for bodyless responses. Every body byte is then passed to Write in order instead of being stored in Response::body, which stays empty; trailers are still returned. body_bytes bounds the total streamed body, so large downloads must raise body_bytes, wire_bytes and timeout explicitly. Returning false or throwing stops the exchange with Error::Rejected and closes the connection; bytes already written are not retracted. Callbacks run synchronously on the Execute thread and must not use the same client.

Constructor & Destructor Documentation

◆ Receiver() [1/3]

StormByte::Network::HTTP::Receiver::Receiver ( )
defaultnoexcept

Construct a stateless receiver base.

◆ Receiver() [2/3]

StormByte::Network::HTTP::Receiver::Receiver ( const Receiver & other)
defaultnoexcept

Copy the stateless base.

Parameters
otherSource receiver.

◆ Receiver() [3/3]

StormByte::Network::HTTP::Receiver::Receiver ( Receiver && other)
defaultnoexcept

Move the stateless base.

Parameters
otherSource receiver.

◆ ~Receiver()

virtual StormByte::Network::HTTP::Receiver::~Receiver ( )
virtualnoexcept

Destroy the receiver.

Member Function Documentation

◆ Begin()

virtual bool StormByte::Network::HTTP::Receiver::Begin ( unsigned short status,
const Safe::Vector< Header > & headers )
pure virtual

Accept or decline the final response before its body.

Parameters
statusFinal three-digit status.
headersFinal fields, preserving duplicates; borrowed for this call.
Returns
Whether to continue receiving the body.

◆ operator=() [1/2]

Receiver & StormByte::Network::HTTP::Receiver::operator= ( const Receiver & other)
defaultnoexcept

Copy the stateless base.

Parameters
otherSource receiver.
Returns
This receiver.

◆ operator=() [2/2]

Receiver & StormByte::Network::HTTP::Receiver::operator= ( Receiver && other)
defaultnoexcept

Move the stateless base.

Parameters
otherSource receiver.
Returns
This receiver.

◆ Write()

virtual bool StormByte::Network::HTTP::Receiver::Write ( std::span< const std::byte > bytes)
pure virtual

Consume the next nonempty body chunk.

Parameters
bytesChunk borrowed for this call only.
Returns
Whether to continue receiving.

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