HTTP module

ChunkedAdapter

HTTP chunked transfer encoding adapter for streaming responses.

ChunkedAdapter

#include <icy/http/packetizers.h>

Inherits: PacketProcessor

HTTP chunked transfer encoding adapter for streaming responses.

Public Attributes

ReturnNameDescription
Connection::PtrconnectionHTTP connection to send the initial response header through.
std::stringcontentTypeContent-Type value for the chunked response.
std::stringframeSeparatorOptional separator written before each chunk payload.
boolinitialTrue until the first chunk is processed and the header emitted.
boolnocopyIf true, header/data/footer are emitted as separate packets.
PacketSignalemitter

connection

Connection::Ptr connection

HTTP connection to send the initial response header through.


contentType

std::string contentType

Content-Type value for the chunked response.


frameSeparator

std::string frameSeparator

Optional separator written before each chunk payload.


initial

bool initial

True until the first chunk is processed and the header emitted.


nocopy

bool nocopy

If true, header/data/footer are emitted as separate packets.


emitter

PacketSignal emitter

Public Methods

ReturnNameDescription
ChunkedAdapter inlineCreates a ChunkedAdapter that sends its initial response header through the given connection. The content type is read from the connection's outgoing header.
ChunkedAdapter inlineCreates a ChunkedAdapter that emits its own raw HTTP/1.1 200 response header. Use this when no Connection object is available.
voidemitHeader virtual inlineEmits the initial HTTP/1.1 200 OK response headers with chunked transfer encoding. If a connection is set, headers are written through it; otherwise a raw response string is emitted via the packet signal.
voidprocess virtual inlineEncodes an incoming packet as a chunked transfer encoding chunk and emits it. Emits the HTTP response headers on the first call.

ChunkedAdapter

inline

inline ChunkedAdapter(Connection::Ptr connection, const std::string & frameSeparator, bool nocopy)

Creates a ChunkedAdapter that sends its initial response header through the given connection. The content type is read from the connection's outgoing header.

Parameters

  • connection HTTP connection to use. May be nullptr to emit a raw response instead.

  • frameSeparator Optional data prepended to each chunk payload.

  • nocopy If true, header and payload are emitted as separate packets (avoids copies).


ChunkedAdapter

inline

inline ChunkedAdapter(const std::string & contentType, const std::string & frameSeparator, bool nocopy)

Creates a ChunkedAdapter that emits its own raw HTTP/1.1 200 response header. Use this when no Connection object is available.

Parameters

  • contentType Content-Type value for the response.

  • frameSeparator Optional data prepended to each chunk payload.

  • nocopy If true, header and payload are emitted as separate packets.


emitHeader

virtual inline

virtual inline void emitHeader()

Emits the initial HTTP/1.1 200 OK response headers with chunked transfer encoding. If a connection is set, headers are written through it; otherwise a raw response string is emitted via the packet signal.


process

virtual inline

virtual inline void process(IPacket & packet)

Encodes an incoming packet as a chunked transfer encoding chunk and emits it. Emits the HTTP response headers on the first call.

Parameters

  • packet Packet containing the raw payload data.

Exceptions

  • std::invalid_argument if the packet does not carry data.