ServerConnection
ServerConnection
#include <icy/http/server.h>class ServerConnectionDefined in src/http/include/icy/http/server.h:59
Inherits:
Connection
HTTP server connection.
List of all members
| Name | Kind | Owner |
|---|---|---|
Payload | variable | Declared here |
Close | variable | Declared here |
ServerConnection | function | Declared here |
~ServerConnection | function | Declared here |
server | function | Declared here |
state | function | Declared here |
mode | function | Declared here |
upgraded | function | Declared here |
streaming | function | Declared here |
idleTimeoutEnabled | function | Declared here |
reusableForPool | function | Declared here |
markActive | function | Declared here |
reset | function | Declared here |
touch | function | Declared here |
idleSeconds | function | Declared here |
beginStreaming | function | Declared here |
endStreaming | function | Declared here |
endStreaming | function | Declared here |
sendHeader | function | Declared here |
close | function | Declared here |
_server | variable | Declared here |
_responder | variable | Declared here |
_lastActivity | variable | Declared here |
_state | variable | Declared here |
_mode | variable | Declared here |
onHeaders | function | Declared here |
onPayload | function | Declared here |
onComplete | function | Declared here |
onClose | function | Declared here |
incomingHeader | function | Declared here |
outgoingHeader | function | Declared here |
setState | function | Declared here |
requestHasBody | function | Declared here |
responseLooksStreaming | function | Declared here |
Ptr | typedef | Declared here |
ConnectionStream | friend | Inherited from Connection |
ConnectionAdapter | friend | Inherited from Connection |
Connection | function | Inherited from Connection |
~Connection | function | Inherited from Connection |
onHeaders | function | Inherited from Connection |
onPayload | function | Inherited from Connection |
onComplete | function | Inherited from Connection |
onClose | function | Inherited from Connection |
send | function | Inherited from Connection |
sendOwned | function | Inherited from Connection |
sendHeader | function | Inherited from Connection |
close | function | Inherited from Connection |
markActive | function | Inherited from Connection |
beginStreaming | function | Inherited from Connection |
endStreaming | function | Inherited from Connection |
closed | function | Inherited from Connection |
error | function | Inherited from Connection |
headerAutoSendEnabled | function | Inherited from Connection |
setHeaderAutoSendEnabled | function | Inherited from Connection |
replaceAdapter | function | Inherited from Connection |
replaceAdapter | function | Inherited from Connection |
secure | function | Inherited from Connection |
socket | function | Inherited from Connection |
adapter | function | Inherited from Connection |
request | function | Inherited from Connection |
response | function | Inherited from Connection |
incomingHeader | function | Inherited from Connection |
outgoingHeader | function | Inherited from Connection |
_socket | variable | Inherited from Connection |
_adapter | variable | Inherited from Connection |
_request | variable | Inherited from Connection |
_response | variable | Inherited from Connection |
_error | variable | Inherited from Connection |
_closed | variable | Inherited from Connection |
_shouldSendHeader | variable | Inherited from Connection |
setError | function | Inherited from Connection |
onSocketConnect | function | Inherited from Connection |
onSocketRecv | function | Inherited from Connection |
onSocketError | function | Inherited from Connection |
onSocketClose | function | Inherited from Connection |
Ptr | typedef | Inherited from Connection |
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 Connection
| Kind | Name | Description |
|---|---|---|
friend | ConnectionStream | |
friend | ConnectionAdapter | |
function | Connection | Creates a Connection using the given TCP socket. |
function | ~Connection virtual noexcept | |
function | onHeaders virtual | Called when the incoming HTTP headers have been fully parsed. |
function | onPayload virtual | Called for each chunk of incoming body data after headers are complete. |
function | onComplete virtual | Called when the incoming HTTP message is fully received. |
function | onClose virtual | Called when the connection is closed. |
function | send virtual override | Send raw data to the peer. |
function | sendOwned virtual override | Send an owned payload buffer to the peer. |
function | sendHeader virtual | Send the outdoing HTTP header. |
function | close virtual | Close the connection and schedule the object for deferred deletion. |
function | markActive virtual inline | Marks the connection as active. Server connections override this to refresh the idle timer. |
function | beginStreaming virtual inline | Explicitly enter long-lived streaming mode. Base connections ignore this; server connections use it to disable keep-alive idle reaping while a response stream is active. |
function | endStreaming virtual inline | Exit long-lived streaming mode. |
function | closed const | Return true if the connection is closed. |
function | error const | Return the error object if any. |
function | headerAutoSendEnabled const | Return true if headers should be automatically sent. |
function | setHeaderAutoSendEnabled | Enable or disable automatic header emission for the next outgoing send path. |
function | replaceAdapter virtual | Assign the new ConnectionAdapter and setup the chain. The flow is: Connection <-> ConnectionAdapter <-> Socket. Takes ownership of the adapter (deferred deletion via uv loop). |
function | replaceAdapter virtual | Overload for nullptr (used in destructor to clear adapter). |
function | secure const | Return true if the connection uses TLS/SSL. |
function | socket | Return the underlying socket pointer. |
function | adapter const | Return the underlying adapter pointer. |
function | request | The HTTP request headers. |
function | response | The HTTP response headers. |
function | incomingHeader virtual | Returns the incoming HTTP message header (request or response depending on role). |
function | outgoingHeader virtual | Returns the outgoing HTTP message header (request or response depending on role). |
variable | _socket | |
variable | _adapter | |
variable | _request | |
variable | _response | |
variable | _error | |
variable | _closed | |
variable | _shouldSendHeader | |
function | setError virtual | Set the internal error. Note: Setting the error does not [close()](icy-http-Connection.html#close-27) the connection. |
function | onSocketConnect virtual override | net::SocketAdapter interface |
function | onSocketRecv virtual override | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual override | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual override | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
typedef | Ptr |
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 Attributes
| 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. |
Payload
LocalSignal< void(ServerConnection &, const MutableBuffer &)> PayloadDefined in src/http/include/icy/http/server.h:118
Signals when raw data is received.
Close
LocalSignal< void(ServerConnection &)> CloseDefined in src/http/include/icy/http/server.h:119
Signals when the connection is closed.
Public Methods
| 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 override | 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 override | Explicitly mark the response as long-lived streaming. Streaming connections are excluded from the keep-alive idle reaper. |
void | endStreaming virtual override | Exit streaming mode and return to the given HTTP state. |
void | endStreaming | |
ssize_t | sendHeader virtual override | Send the outgoing HTTP header. |
void | close virtual override | Close the connection with an explicit terminal state transition. |
ServerConnection
ServerConnection(Server & server, net::TCPSocket::Ptr socket)Defined in src/http/include/icy/http/server.h:67
Creates a ServerConnection attached to the given server and socket.
Parameters
serverThe owning HTTP server instance.socketThe accepted TCP socket for this connection.
server
Server & server()Defined in src/http/include/icy/http/server.h:71
Returns the owning Server instance.
state
const inline
inline ServerConnectionState state() constDefined in src/http/include/icy/http/server.h:74
Returns the current server-side connection state.
mode
const inline
inline ServerConnectionMode mode() constDefined in src/http/include/icy/http/server.h:77
Returns the current transport mode.
upgraded
const inline
inline bool upgraded() constDefined in src/http/include/icy/http/server.h:80
Returns true if the connection has been upgraded (e.g. to WebSocket).
streaming
const inline
inline bool streaming() constDefined in src/http/include/icy/http/server.h:83
Returns true if the connection is in long-lived streaming mode.
idleTimeoutEnabled
const
bool idleTimeoutEnabled() constDefined in src/http/include/icy/http/server.h:86
Returns true if the server idle timer is allowed to reap this connection.
reusableForPool
const
bool reusableForPool() constDefined in src/http/include/icy/http/server.h:89
Returns true if the closed connection can be returned to the reuse pool.
markActive
virtual inline override
virtual inline void markActive() overrideDefined in src/http/include/icy/http/server.h:92
Refresh the idle timer.
Reimplements
reset
void reset(net::TCPSocket::Ptr socket)Defined in src/http/include/icy/http/server.h:96
Reset this connection for reuse with a new socket. Called by the connection pool to avoid allocating a new ServerConnection.
touch
inline
inline void touch()Defined in src/http/include/icy/http/server.h:99
Update the last activity timestamp.
idleSeconds
const inline
inline double idleSeconds() constDefined in src/http/include/icy/http/server.h:102
Return seconds since last activity.
beginStreaming
virtual override
virtual void beginStreaming() overrideDefined in src/http/include/icy/http/server.h:106
Explicitly mark the response as long-lived streaming. Streaming connections are excluded from the keep-alive idle reaper.
Reimplements
endStreaming
virtual override
virtual void endStreaming() overrideDefined in src/http/include/icy/http/server.h:109
Exit streaming mode and return to the given HTTP state.
Reimplements
endStreaming
void endStreaming(ServerConnectionState nextState)Defined in src/http/include/icy/http/server.h:110
sendHeader
virtual override
virtual ssize_t sendHeader() overrideDefined in src/http/include/icy/http/server.h:113
Send the outgoing HTTP header.
Reimplements
close
virtual override
virtual void close() overrideDefined in src/http/include/icy/http/server.h:116
Close the connection with an explicit terminal state transition.
Reimplements
Protected Attributes
| Return | Name | Description |
|---|---|---|
Server & | _server | |
std::unique_ptr< ServerResponder > | _responder | |
std::time_t | _lastActivity | |
ServerConnectionState | _state | |
ServerConnectionMode | _mode |
_server
Server & _serverDefined in src/http/include/icy/http/server.h:135
_responder
std::unique_ptr< ServerResponder > _responderDefined in src/http/include/icy/http/server.h:136
_lastActivity
std::time_t _lastActivity {0}Defined in src/http/include/icy/http/server.h:137
_state
ServerConnectionState _state {}Defined in src/http/include/icy/http/server.h:138
_mode
ServerConnectionMode _mode {}Defined in src/http/include/icy/http/server.h:139
Protected Methods
| Return | Name | Description |
|---|---|---|
void | onHeaders virtual override | Called when the incoming HTTP headers have been fully parsed. |
void | onPayload virtual override | Called for each chunk of incoming body data after headers are complete. |
void | onComplete virtual override | Called when the incoming HTTP message is fully received. |
void | onClose virtual override | Called when the connection is closed. |
http::Message * | incomingHeader virtual override | Returns the incoming HTTP message header (request or response depending on role). |
http::Message * | outgoingHeader virtual override | Returns the outgoing HTTP message header (request or response depending on role). |
void | setState | |
bool | requestHasBody const | |
bool | responseLooksStreaming const |
onHeaders
virtual override
virtual void onHeaders() overrideDefined in src/http/include/icy/http/server.h:122
Called when the incoming HTTP headers have been fully parsed.
Reimplements
onPayload
virtual override
virtual void onPayload(const MutableBuffer & buffer) overrideDefined in src/http/include/icy/http/server.h:123
Called for each chunk of incoming body data after headers are complete.
Parameters
bufferBuffer containing the received data chunk.
Reimplements
onComplete
virtual override
virtual void onComplete() overrideDefined in src/http/include/icy/http/server.h:124
Called when the incoming HTTP message is fully received.
Reimplements
onClose
virtual override
virtual void onClose() overrideDefined in src/http/include/icy/http/server.h:125
Called when the connection is closed.
Reimplements
incomingHeader
virtual override
virtual http::Message * incomingHeader() overrideDefined in src/http/include/icy/http/server.h:127
Returns the incoming HTTP message header (request or response depending on role).
Reimplements
outgoingHeader
virtual override
virtual http::Message * outgoingHeader() overrideDefined in src/http/include/icy/http/server.h:128
Returns the outgoing HTTP message header (request or response depending on role).
Reimplements
setState
void setState(ServerConnectionState state)Defined in src/http/include/icy/http/server.h:130
requestHasBody
const
bool requestHasBody() constDefined in src/http/include/icy/http/server.h:131
responseLooksStreaming
const
bool responseLooksStreaming() constDefined in src/http/include/icy/http/server.h:132
Public Types
| Name | Description |
|---|---|
Ptr |
Ptr
using Ptr = std::shared_ptr< ServerConnection >