#include <icy/http/connection.h>Inherits:
ParserObserver,SocketAdapter
Default HTTP socket adapter for reading and writing HTTP messages
| Return | Name | Description |
|---|---|---|
ConnectionAdapter | Creates a ConnectionAdapter for the given connection. | |
ssize_t | send virtual | Sends data to the peer, flushing the outgoing HTTP header first if needed. |
ssize_t | sendOwned virtual | Sends an owned payload buffer to the connected peer. |
void | removeReceiver | 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(Connection * connection, llhttp_type_t type)Creates a ConnectionAdapter for the given connection.
connection Owning HTTP connection.
type Parser type: HTTP_REQUEST for server side, HTTP_RESPONSE for client side.
virtual
virtual ssize_t send(const char * data, size_t len, int flags)Sends data to the peer, flushing the outgoing HTTP header first if needed.
data Pointer to the data buffer.
len Number of bytes to send.
flags Send flags (unused for HTTP, used for WebSocket frame type).
Number of bytes sent, or -1 on error.
virtual
virtual ssize_t sendOwned(Buffer && buffer, int flags)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.
void removeReceiver(SocketAdapter * adapter)Remove the given receiver.
By default this function does nothing unless the given receiver matches the current receiver.
Parser & parser()Returns the HTTP parser instance.
Connection * connection()Returns the owning Connection pointer, or nullptr if detached.
void reset(net::SocketAdapter * sender, http::Request * request)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.
sender New socket adapter to send data through.
request New HTTP request object for the parser to populate.
| Return | Name | Description |
|---|---|---|
Connection * | _connection | |
Parser | _parser |
Connection * _connectionParser _parser| Return | Name | Description |
|---|---|---|
bool | onSocketRecv virtual | SocketAdapter interface. |
void | onParserHeader virtual | HTTP Parser interface. |
void | onParserHeadersEnd virtual | Called when all HTTP headers have been parsed. |
void | onParserChunk virtual | Called for each chunk of body data received. |
void | onParserError virtual | Called when a parse error occurs. |
void | onParserEnd virtual | Called when the HTTP message is fully parsed. |
virtual
virtual bool onSocketRecv(net::Socket & socket, const MutableBuffer & buffer, const net::Address & peerAddress)SocketAdapter interface.
virtual
virtual void onParserHeader(const std::string & name, const std::string & value)HTTP Parser interface.
virtual
virtual void onParserHeadersEnd(bool upgrade)Called when all HTTP headers have been parsed.
upgrade True if the connection should be upgraded (e.g. to WebSocket).virtual
virtual void onParserChunk(const char * data, size_t len)Called for each chunk of body data received.
data Pointer to the body data chunk.
len Length of the chunk in bytes.
virtual
virtual void onParserError(const icy::Error & err)Called when a parse error occurs.
err Error details from llhttp.virtual
virtual void onParserEnd()Called when the HTTP message is fully parsed.