ConnectionAdapter
ConnectionAdapter
#include <icy/http/connection.h>class ConnectionAdapterDefined in src/http/include/icy/http/connection.h:160
Inherits:
ParserObserver,SocketAdapter
Default HTTP socket adapter for reading and writing HTTP messages
List of all members
| Name | Kind | Owner |
|---|---|---|
ConnectionAdapter | function | Declared here |
~ConnectionAdapter | function | Declared here |
send | function | Declared here |
sendOwned | function | Declared here |
removeReceiver | function | Declared here |
parser | function | Declared here |
connection | function | Declared here |
reset | function | Declared here |
_connection | variable | Declared here |
_parser | variable | Declared here |
onSocketRecv | function | Declared here |
onParserHeader | function | Declared here |
onParserHeadersEnd | function | Declared here |
onParserChunk | function | Declared here |
onParserError | function | Declared here |
onParserEnd | function | Declared here |
onParserHeader | function | Inherited from ParserObserver |
onParserHeadersEnd | function | Inherited from ParserObserver |
onParserChunk | function | Inherited from ParserObserver |
onParserEnd | function | Inherited from ParserObserver |
onParserError | function | Inherited from ParserObserver |
priority | variable | Inherited from SocketAdapter |
SocketAdapter | function | Inherited from SocketAdapter |
~SocketAdapter | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
setSender | function | Inherited from SocketAdapter |
sender | function | Inherited from SocketAdapter |
addReceiver | function | Inherited from SocketAdapter |
removeReceiver | function | Inherited from SocketAdapter |
hasReceiver | function | Inherited from SocketAdapter |
receivers | function | Inherited from SocketAdapter |
onSocketConnect | function | Inherited from SocketAdapter |
onSocketRecv | function | Inherited from SocketAdapter |
onSocketError | function | Inherited from SocketAdapter |
onSocketClose | function | Inherited from SocketAdapter |
_sender | variable | Inherited from SocketAdapter |
_receivers | variable | Inherited from SocketAdapter |
_dirty | variable | Inherited from SocketAdapter |
cleanupReceivers | function | Inherited from SocketAdapter |
Inherited from ParserObserver
| Kind | Name | Description |
|---|---|---|
function | onParserHeader virtual | Called for each parsed HTTP header name/value pair. |
function | onParserHeadersEnd virtual | Called when all HTTP headers have been parsed. |
function | onParserChunk virtual | Called for each chunk of body data received. |
function | onParserEnd virtual | Called when the HTTP message is fully parsed. |
function | onParserError virtual | Called when a parse error occurs. |
Inherited from SocketAdapter
| Kind | Name | Description |
|---|---|---|
variable | priority | The priority of this adapter for STL sort operations. |
function | SocketAdapter | Creates the SocketAdapter. |
function | ~SocketAdapter virtual noexcept | Destroys the SocketAdapter. |
function | send virtual | Sends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | send virtual | |
function | sendOwned virtual | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual | |
function | sendPacket virtual | Sends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | sendPacket virtual | |
function | sendPacket virtual | Sends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed. |
function | setSender virtual | Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default. |
function | sender | Returns the output SocketAdapter pointer. |
function | addReceiver virtual | Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default. |
function | removeReceiver virtual | Remove the given receiver. |
function | hasReceiver virtual | Returns true if the given receiver is connected. |
function | receivers | Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list. |
function | onSocketConnect virtual | Called when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event. |
function | onSocketRecv virtual | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
variable | _sender | |
variable | _receivers | |
variable | _dirty | |
function | cleanupReceivers virtual |
Public Methods
| Return | Name | Description |
|---|---|---|
ConnectionAdapter | Creates a ConnectionAdapter for the given connection. | |
ssize_t | send virtual override | Sends data to the peer, flushing the outgoing HTTP header first if needed. |
ssize_t | sendOwned virtual override | Sends an owned payload buffer to the connected peer. |
void | removeReceiver override | Remove the given receiver. |
Parser & | parser | Returns the HTTP parser instance. |
Connection * | connection | Returns the owning Connection pointer, or nullptr if detached. |
void | reset | Resets the adapter for reuse with a new socket and request. Clears the parser state and re-wires the sender without reallocating. Used by the connection pool to avoid destroying/recreating adapters. |
ConnectionAdapter
ConnectionAdapter(Connection * connection, llhttp_type_t type)Defined in src/http/include/icy/http/connection.h:167
Creates a ConnectionAdapter for the given connection.
Parameters
connectionOwning HTTP connection.typeParser type: HTTP_REQUEST for server side, HTTP_RESPONSE for client side.
send
virtual override
virtual ssize_t send(const char * data, size_t len, int flags = 0) overrideDefined in src/http/include/icy/http/connection.h:175
Sends data to the peer, flushing the outgoing HTTP header first if needed.
Parameters
dataPointer to the data buffer.lenNumber of bytes to send.flagsSend flags (unused for HTTP, used for WebSocket frame type).
Returns
Number of bytes sent, or -1 on error.
Reimplements
sendOwned
virtual override
virtual ssize_t sendOwned(Buffer && buffer, int flags = 0) overrideDefined in src/http/include/icy/http/connection.h:176
Sends an owned payload buffer to the connected peer.
The buffer is moved through the adapter chain and retained by the transport layer until async write completion.
Reimplements
removeReceiver
override
void removeReceiver(SocketAdapter * adapter) overrideDefined in src/http/include/icy/http/connection.h:182
Remove the given receiver.
By default this function does nothing unless the given receiver matches the current receiver.
parser
Parser & parser()Defined in src/http/include/icy/http/connection.h:185
Returns the HTTP parser instance.
connection
Connection * connection()Defined in src/http/include/icy/http/connection.h:188
Returns the owning Connection pointer, or nullptr if detached.
reset
void reset(net::SocketAdapter * sender, http::Request * request)Defined in src/http/include/icy/http/connection.h:195
Resets the adapter for reuse with a new socket and request. Clears the parser state and re-wires the sender without reallocating. Used by the connection pool to avoid destroying/recreating adapters.
Parameters
senderNew socket adapter to send data through.requestNew HTTP request object for the parser to populate.
Protected Attributes
| Return | Name | Description |
|---|---|---|
Connection * | _connection | |
Parser | _parser |
_connection
Connection * _connectionDefined in src/http/include/icy/http/connection.h:208
_parser
Parser _parserDefined in src/http/include/icy/http/connection.h:209
Protected Methods
| Return | Name | Description |
|---|---|---|
bool | onSocketRecv virtual override | SocketAdapter interface. |
void | onParserHeader virtual override | HTTP Parser interface. |
void | onParserHeadersEnd virtual override | Called when all HTTP headers have been parsed. |
void | onParserChunk virtual override | Called for each chunk of body data received. |
void | onParserError virtual override | Called when a parse error occurs. |
void | onParserEnd virtual override | Called when the HTTP message is fully parsed. |
onSocketRecv
virtual override
virtual bool onSocketRecv(net::Socket & socket, const MutableBuffer & buffer, const net::Address & peerAddress) overrideDefined in src/http/include/icy/http/connection.h:199
SocketAdapter interface.
Reimplements
onParserHeader
virtual override
virtual void onParserHeader(const std::string & name, const std::string & value) overrideDefined in src/http/include/icy/http/connection.h:202
HTTP Parser interface.
Reimplements
onParserHeadersEnd
virtual override
virtual void onParserHeadersEnd(bool upgrade) overrideDefined in src/http/include/icy/http/connection.h:203
Called when all HTTP headers have been parsed.
Parameters
upgradeTrue if the connection should be upgraded (e.g. to WebSocket).
Reimplements
onParserChunk
virtual override
virtual void onParserChunk(const char * data, size_t len) overrideDefined in src/http/include/icy/http/connection.h:204
Called for each chunk of body data received.
Parameters
dataPointer to the body data chunk.lenLength of the chunk in bytes.
Reimplements
onParserError
virtual override
virtual void onParserError(const icy::Error & err) overrideDefined in src/http/include/icy/http/connection.h:205
Called when a parse error occurs.
Parameters
errError details from llhttp.
Reimplements
onParserEnd
virtual override
virtual void onParserEnd() overrideDefined in src/http/include/icy/http/connection.h:206
Called when the HTTP message is fully parsed.
