ChunkedAdapter
ChunkedAdapter
#include <icy/http/packetizers.h>Inherits:
PacketProcessor
HTTP chunked transfer encoding adapter for streaming responses.
Public Attributes
| Return | Name | Description |
|---|---|---|
Connection::Ptr | connection | HTTP connection to send the initial response header through. |
std::string | contentType | Content-Type value for the chunked response. |
std::string | frameSeparator | Optional separator written before each chunk payload. |
bool | initial | True until the first chunk is processed and the header emitted. |
bool | nocopy | If true, header/data/footer are emitted as separate packets. |
PacketSignal | emitter |
connection
Connection::Ptr connectionHTTP connection to send the initial response header through.
contentType
std::string contentTypeContent-Type value for the chunked response.
frameSeparator
std::string frameSeparatorOptional separator written before each chunk payload.
initial
bool initialTrue until the first chunk is processed and the header emitted.
nocopy
bool nocopyIf true, header/data/footer are emitted as separate packets.
emitter
PacketSignal emitterPublic Methods
| Return | Name | Description |
|---|---|---|
ChunkedAdapter inline | Creates a ChunkedAdapter that sends its initial response header through the given connection. The content type is read from the connection's outgoing header. | |
ChunkedAdapter inline | Creates a ChunkedAdapter that emits its own raw HTTP/1.1 200 response header. Use this when no Connection object is available. | |
void | emitHeader virtual inline | 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. |
void | process virtual inline | Encodes 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
connectionHTTP connection to use. May be nullptr to emit a raw response instead.frameSeparatorOptional data prepended to each chunk payload.nocopyIf 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
contentTypeContent-Type value for the response.frameSeparatorOptional data prepended to each chunk payload.nocopyIf 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
packetPacket containing the raw payload data.
Exceptions
std::invalid_argumentif the packet does not carry data.
