Home
HTTP module

ChunkedAdapter

HTTP chunked transfer encoding adapter for streaming responses.

ChunkedAdapter

#include <icy/http/packetizers.h>
class ChunkedAdapter

Defined in src/http/include/icy/http/packetizers.h:29

Inherits: PacketProcessor

HTTP chunked transfer encoding adapter for streaming responses.

List of all members

NameKindOwner
connectionvariableDeclared here
contentTypevariableDeclared here
frameSeparatorvariableDeclared here
initialvariableDeclared here
nocopyvariableDeclared here
emittervariableDeclared here
ChunkedAdapterfunctionDeclared here
ChunkedAdapterfunctionDeclared here
~ChunkedAdapterfunctionDeclared here
emitHeaderfunctionDeclared here
processfunctionDeclared here
PacketProcessorfunctionInherited from PacketProcessor
processfunctionInherited from PacketProcessor
acceptsfunctionInherited from PacketProcessor
operator<<functionInherited from PacketProcessor
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
~PacketStreamAdapterfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
getEmitterfunctionInherited from PacketStreamAdapter
retentionfunctionInherited from PacketStreamAdapter
onStreamStateChangefunctionInherited from PacketStreamAdapter
_emittervariableInherited from PacketStreamAdapter
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
operator=functionInherited from PacketStreamAdapter
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
operator=functionInherited from PacketStreamAdapter

Inherited from PacketProcessor

KindNameDescription
functionPacketProcessor inline
functionprocess virtualThis method performs processing on the given packet and emits the result.
functionaccepts virtual inlineThis method ensures compatibility with the given packet type. Return false to reject the packet.
functionoperator<< virtual inlineStream operator alias for process()

Inherited from PacketStreamAdapter

KindNameDescription
functionPacketStreamAdapterConstruct the adapter, binding it to the given packet signal.
function~PacketStreamAdapter virtual inline
functionemit virtualEmit a mutable raw buffer as a packet.
functionemit virtualEmit a read-only raw buffer as a packet (data is copied internally).
functionemit virtualEmit a string as a packet (data is copied internally).
functionemit virtualEmit a flag-only packet carrying no payload data.
functionemit virtualEmit an existing packet directly onto the outgoing signal.
functiongetEmitterReturns a reference to the outgoing packet signal.
functionretention virtual constReturns how this adapter treats incoming packet lifetime. Most adapters are synchronous and therefore only borrow the packet for the current call chain. Queue-style adapters override this to advertise that they clone before deferred use. Callers may treat the first adapter reporting Cloned or Retained as the explicit ownership boundary in the stream graph.
functiononStreamStateChange virtual inlineCalled by the PacketStream to notify when the internal Stream state changes. On receiving the Stopped state, it is the responsibility of the adapter to have ceased all outgoing packet transmission, especially in multi-thread scenarios.
variable_emitter
functionPacketStreamAdapterNonCopyable and NonMovable.
functionoperator=Deleted assignment operator.
functionPacketStreamAdapterDeleted constructor.
functionoperator=Deleted assignment operator.

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

Defined in src/http/include/icy/http/packetizers.h:32

HTTP connection to send the initial response header through.


contentType

std::string contentType

Defined in src/http/include/icy/http/packetizers.h:33

Content-Type value for the chunked response.


frameSeparator

std::string frameSeparator

Defined in src/http/include/icy/http/packetizers.h:34

Optional separator written before each chunk payload.


initial

bool initial

Defined in src/http/include/icy/http/packetizers.h:35

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


nocopy

bool nocopy

Defined in src/http/include/icy/http/packetizers.h:36

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


emitter

PacketSignal emitter

Defined in src/http/include/icy/http/packetizers.h:148

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 inline overrideEncodes 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 = nullptr, const std::string & frameSeparator = "", bool nocopy = true)

Defined in src/http/include/icy/http/packetizers.h:43

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 = true)

Defined in src/http/include/icy/http/packetizers.h:56

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()

Defined in src/http/include/icy/http/packetizers.h:71

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 override

virtual inline void process(IPacket & packet) override

Defined in src/http/include/icy/http/packetizers.h:110

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.
Reimplements