#include <icy/http/server.h>Inherits:
Connection
HTTP server connection.
| Return | Name | Description |
|---|---|---|
LocalSignal< void(ServerConnection &, const MutableBuffer &)> | Payload | Signals when raw data is received. |
LocalSignal< void(ServerConnection &)> | Close | Signals when the connection is closed. |
LocalSignal< void(ServerConnection &, const MutableBuffer &)> PayloadSignals when raw data is received.
LocalSignal< void(ServerConnection &)> CloseSignals when the connection is closed.
| Return | Name | Description |
|---|---|---|
ServerConnection | Creates a ServerConnection attached to the given server and socket. | |
Server & | server | Returns the owning Server instance. |
ServerConnectionState | state const inline | Returns the current server-side connection state. |
ServerConnectionMode | mode const inline | Returns the current transport mode. |
bool | upgraded const inline | Returns true if the connection has been upgraded (e.g. to WebSocket). |
bool | streaming const inline | Returns true if the connection is in long-lived streaming mode. |
bool | idleTimeoutEnabled const | Returns true if the server idle timer is allowed to reap this connection. |
bool | reusableForPool const | Returns true if the closed connection can be returned to the reuse pool. |
void | markActive virtual inline | Refresh the idle timer. |
void | reset | Reset this connection for reuse with a new socket. Called by the connection pool to avoid allocating a new ServerConnection. |
void | touch inline | Update the last activity timestamp. |
double | idleSeconds const inline | Return seconds since last activity. |
void | beginStreaming virtual | Explicitly mark the response as long-lived streaming. Streaming connections are excluded from the keep-alive idle reaper. |
void | endStreaming virtual | Exit streaming mode and return to the given HTTP state. |
void | endStreaming | |
ssize_t | sendHeader virtual | Send the outgoing HTTP header. |
void | close virtual | Close the connection with an explicit terminal state transition. |
ServerConnection(Server & server, net::TCPSocket::Ptr socket)Creates a ServerConnection attached to the given server and socket.
server The owning HTTP server instance.
socket The accepted TCP socket for this connection.
Server & server()Returns the owning Server instance.
const inline
inline ServerConnectionState state() constReturns the current server-side connection state.
const inline
inline ServerConnectionMode mode() constReturns the current transport mode.
const inline
inline bool upgraded() constReturns true if the connection has been upgraded (e.g. to WebSocket).
const inline
inline bool streaming() constReturns true if the connection is in long-lived streaming mode.
const
bool idleTimeoutEnabled() constReturns true if the server idle timer is allowed to reap this connection.
const
bool reusableForPool() constReturns true if the closed connection can be returned to the reuse pool.
virtual inline
virtual inline void markActive()Refresh the idle timer.
void reset(net::TCPSocket::Ptr socket)Reset this connection for reuse with a new socket. Called by the connection pool to avoid allocating a new ServerConnection.
inline
inline void touch()Update the last activity timestamp.
const inline
inline double idleSeconds() constReturn seconds since last activity.
virtual
virtual void beginStreaming()Explicitly mark the response as long-lived streaming. Streaming connections are excluded from the keep-alive idle reaper.
virtual
virtual void endStreaming()Exit streaming mode and return to the given HTTP state.
void endStreaming(ServerConnectionState nextState)virtual
virtual ssize_t sendHeader()Send the outgoing HTTP header.
virtual
virtual void close()Close the connection with an explicit terminal state transition.
| Return | Name | Description |
|---|---|---|
Server & | _server | |
std::unique_ptr< ServerResponder > | _responder | |
std::time_t | _lastActivity | |
ServerConnectionState | _state | |
ServerConnectionMode | _mode |
Server & _serverstd::unique_ptr< ServerResponder > _responderstd::time_t _lastActivity {0}ServerConnectionState _state {}ServerConnectionMode _mode {}| Return | Name | Description |
|---|---|---|
void | onHeaders virtual | Called when the incoming HTTP headers have been fully parsed. |
void | onPayload virtual | Called for each chunk of incoming body data after headers are complete. |
void | onComplete virtual | Called when the incoming HTTP message is fully received. |
void | onClose virtual | Called when the connection is closed. |
http::Message * | incomingHeader virtual | Returns the incoming HTTP message header (request or response depending on role). |
http::Message * | outgoingHeader virtual | Returns the outgoing HTTP message header (request or response depending on role). |
void | setState | |
bool | requestHasBody const | |
bool | responseLooksStreaming const |
virtual
virtual void onHeaders()Called when the incoming HTTP headers have been fully parsed.
virtual
virtual void onPayload(const MutableBuffer & buffer)Called for each chunk of incoming body data after headers are complete.
buffer Buffer containing the received data chunk.virtual
virtual void onComplete()Called when the incoming HTTP message is fully received.
virtual
virtual void onClose()Called when the connection is closed.
virtual
virtual http::Message * incomingHeader()Returns the incoming HTTP message header (request or response depending on role).
virtual
virtual http::Message * outgoingHeader()Returns the outgoing HTTP message header (request or response depending on role).
void setState(ServerConnectionState state)const
bool requestHasBody() constconst
bool responseLooksStreaming() const| Name | Description |
|---|---|
Ptr |
std::shared_ptr< ServerConnection > Ptr()