http

May 15, 2026 ยท View on GitHub

{#httpmodule}

http

HTTP client/server, WebSocket support, form handling, cookies, URL parsing.

Namespaces

NameDescription
httpHTTP request/response types, parsers, and server/client helpers.
wsWebSocket framing, handshakes, and connection helpers.

{#http}

http

HTTP request/response types, parsers, and server/client helpers.

Classes

NameDescription
AuthenticatorMaintains HTTP Basic or Digest authentication state for outbound requests.
BasicAuthenticatorEncodes and decodes HTTP Basic authentication credentials.
ChunkedAdapterHTTP chunked transfer encoding adapter for streaming responses.
ClientHTTP client for creating and managing outgoing connections.
ClientConnectionHTTP client connection for managing request/response lifecycle.
ConnectionBase HTTP connection managing socket I/O and message lifecycle
ConnectionAdapterDefault HTTP socket adapter for reading and writing HTTP messages
ConnectionPoolLIFO connection pool for reusing ServerConnection objects. Avoids per-request heap allocation by resetting and reusing connections instead of destroying and recreating them.
ConnectionStreamPacket stream wrapper for an HTTP connection.
CookieHTTP cookie value plus its response/header attributes.
FilePartForm part backed by a file on disk.
FormPartAn implementation of FormPart.
FormWriterFormWriter is an HTTP client connection adapter for writing HTML forms.
MessageThe base class for Request and Response.
MultipartAdapterHTTP multipart encoding adapter for multipart/x-mixed-replace streaming.
ParserHTTP request/response parser using the llhttp library.
ParserObserverAbstract observer interface for HTTP parser events.
ProgressSignalHTTP progress signal for upload and download progress notifications.
RequestHTTP request message with method, URI, headers, and optional body.
ResponseHTTP response message with status, reason phrase, headers, and body metadata.
ServerHTTP server implementation.
ServerConnectionHTTP server connection.
ServerConnectionFactoryFactory for creating per-socket [ServerConnection](#serverconnection-1) and per-request [ServerResponder](#serverresponder) objects.
ServerResponderBase responder interface for handling one HTTP request on a server connection. Derived classes typically override [onRequest()](#onrequest) and optionally the streaming hooks.
StringPartForm part backed by an in-memory string payload.
URLAn RFC 3986 based URL parser. Constructors and assignment operators will throw a SyntaxException if the URL is invalid.
DateCacheCaches the formatted Date header, updated once per second. Avoids per-request time formatting and string allocation.
MethodHTTP request methods.
StaticFileInfoMetadata needed to serve a static file with HTTP validators.

Enumerations

NameDescription
StatusCodeHTTP Response Status Codes.
ServerConnectionStateHTTP server-side lifecycle phases used by the keep-alive state machine.
ServerConnectionModeTransport mode for server connections before and after protocol upgrade.

{#statuscode}

StatusCode

enum StatusCode

HTTP Response Status Codes.

ValueDescription
Continue
SwitchingProtocols
OK
Created
Accepted
NonAuthoritative
NoContent
ResetContent
PartialContent
MultipleChoices
MovedPermanently
Found
SeeOther
NotModified
UseProxy
TemporaryRedirect
BadRequest
Unauthorized
PaymentRequired
Forbidden
NotFound
MethodNotAllowed
NotAcceptable
ProxyAuthRequired
RequestTimeout
Conflict
Gone
LengthRequired
PreconditionFailed
EntityTooLarge
UriTooLong
UnsupportedMediaType
RangeNotSatisfiable
ExpectationFailed
UnprocessableEntity
UpgradeRequired
InternalServerError
NotImplemented
BadGateway
Unavailable
GatewayTimeout
VersionNotSupported

{#serverconnectionstate}

ServerConnectionState

enum ServerConnectionState

HTTP server-side lifecycle phases used by the keep-alive state machine.

ValueDescription
ReceivingHeadersParsing request headers.
ReceivingBodyReceiving request body bytes.
DispatchingOrSendingDispatching the responder or sending a normal response.
StreamingSending a long-lived streaming response.
UpgradedUpgraded to a non-HTTP protocol such as WebSocket.
ClosingClose has been requested and teardown is in progress.
ClosedConnection has fully closed.

{#serverconnectionmode}

ServerConnectionMode

enum ServerConnectionMode

Transport mode for server connections before and after protocol upgrade.

ValueDescription
HttpStandard HTTP request/response mode.
UpgradedUpgraded transport mode owned by another protocol adapter.

Typedefs

ReturnNameDescription
std::vector< ClientConnection::Ptr >ClientConnectionPtrVecList of owned client connections tracked by an HTTP client.

{#clientconnectionptrvec}

ClientConnectionPtrVec

using ClientConnectionPtrVec = std::vector< ClientConnection::Ptr >

List of owned client connections tracked by an HTTP client.

Functions

ReturnNameDescription
boolisBasicCredentials nodiscardReturns true if the given Authorization header value uses HTTP Basic authentication.
boolisDigestCredentials nodiscardReturns true if the given Authorization header value uses HTTP Digest authentication.
boolhasBasicCredentials nodiscardReturns true if the request contains a Basic Authorization header.
boolhasDigestCredentials nodiscardReturns true if the request contains a Digest Authorization header.
boolhasProxyBasicCredentials nodiscardReturns true if the request contains a Basic Proxy-Authorization header.
boolhasProxyDigestCredentials nodiscardReturns true if the request contains a Digest Proxy-Authorization header.
voidextractCredentialsSplits a "user:password" user-info string into separate username and password strings. If no ':' is present, the entire string is treated as the username and password is empty.
voidextractCredentialsExtracts username and password from the user-info component of a URL. Does nothing if the URL has no user-info part.
ClientConnection::PtrcreateConnectionT inlineCreates a ClientConnection (or subtype) for the given URL without registering it with a Client instance. The socket and adapter are chosen based on the URL scheme:
ClientConnection::PtrcreateConnection inlineCreates a ClientConnection for the given URL and optionally registers it with a Client. Equivalent to calling Client::createConnection() when client is non-null.
const char *getStatusCodeReason nodiscardReturns the standard reason phrase for the given HTTP status code (e.g. "OK" for StatusCode::OK, "Not Found" for StatusCode::NotFound).
const char *getStatusCodeString nodiscardReturns a combined "NNN Reason" string for the given HTTP status code (e.g. "200 OK").
boolstatStaticFileRead static-file metadata from disk.
boolprepareStaticFileResponseApply static-file headers and request conditionals to the response.
std::stringparseURIExtracts the URI (path and query) from a raw HTTP request line.
boolmatchURLTests whether a URI matches a glob-style expression.
std::stringparseCookieItemExtracts a named attribute from a Cookie header value.
boolsplitURIParametersParses URL query parameters from a URI into key-value pairs. Handles percent-decoding of names and values.
voidsplitParametersSplits a header-style parameter string into a primary value and named attributes. Attributes are separated by ';'. Enclosing quotes are stripped from values.
voidsplitParametersSplits a substring (defined by iterators) into named attributes. Attributes are separated by ';'. Enclosing quotes are stripped from values.

{#isbasiccredentials}

isBasicCredentials

nodiscard

[[nodiscard]] bool isBasicCredentials(std::string_view header)

Returns true if the given Authorization header value uses HTTP Basic authentication.

Parameters

  • header Value of the Authorization or WWW-Authenticate header.

{#isdigestcredentials}

isDigestCredentials

nodiscard

[[nodiscard]] bool isDigestCredentials(std::string_view header)

Returns true if the given Authorization header value uses HTTP Digest authentication.

Parameters

  • header Value of the Authorization or WWW-Authenticate header.

{#hasbasiccredentials}

hasBasicCredentials

nodiscard

[[nodiscard]] bool hasBasicCredentials(const http::Request & request)

Returns true if the request contains a Basic Authorization header.

Parameters

  • request HTTP request to inspect.

{#hasdigestcredentials}

hasDigestCredentials

nodiscard

[[nodiscard]] bool hasDigestCredentials(const http::Request & request)

Returns true if the request contains a Digest Authorization header.

Parameters

  • request HTTP request to inspect.

{#hasproxybasiccredentials}

hasProxyBasicCredentials

nodiscard

[[nodiscard]] bool hasProxyBasicCredentials(const http::Request & request)

Returns true if the request contains a Basic Proxy-Authorization header.

Parameters

  • request HTTP request to inspect.

{#hasproxydigestcredentials}

hasProxyDigestCredentials

nodiscard

[[nodiscard]] bool hasProxyDigestCredentials(const http::Request & request)

Returns true if the request contains a Digest Proxy-Authorization header.

Parameters

  • request HTTP request to inspect.

{#extractcredentials}

extractCredentials

void extractCredentials(std::string_view userInfo, std::string & username, std::string & password)

Splits a "user:password" user-info string into separate username and password strings. If no ':' is present, the entire string is treated as the username and password is empty.

Parameters

  • userInfo Input string in the form "user:password".

  • username Receives the extracted username.

  • password Receives the extracted password.


{#extractcredentials-1}

extractCredentials

void extractCredentials(const http::URL & uri, std::string & username, std::string & password)

Extracts username and password from the user-info component of a URL. Does nothing if the URL has no user-info part.

Parameters

  • uri URL to extract credentials from.

  • username Receives the extracted username.

  • password Receives the extracted password.


{#createconnectiont}

createConnectionT

inline

template<class ConnectionT> inline ClientConnection::Ptr createConnectionT(const URL & url, uv::Loop * loop = uv::defaultLoop())

Creates a ClientConnection (or subtype) for the given URL without registering it with a Client instance. The socket and adapter are chosen based on the URL scheme:

  • "http" -> TCPSocket

  • "https" -> SSLSocket

  • "ws" -> TCPSocket + WebSocket adapter

  • "wss" -> SSLSocket + WebSocket adapter

Parameters

Parameters

  • url Target URL. Must have a recognised scheme.

  • loop Event loop to use. Defaults to the default libuv loop.

Returns

Shared pointer to the created connection.

Exceptions

  • std::runtime_error if the URL scheme is not recognised.

{#createconnection}

createConnection

inline

inline ClientConnection::Ptr createConnection(const URL & url, http::Client * client = nullptr, uv::Loop * loop = uv::defaultLoop())

Creates a ClientConnection for the given URL and optionally registers it with a Client. Equivalent to calling Client::createConnection() when client is non-null.

Parameters

  • url Target URL. The scheme determines the socket and adapter type.

  • client Optional Client instance to register the connection with.

  • loop Event loop to use. Defaults to the default libuv loop.

Returns

Shared pointer to the created connection.


{#getstatuscodereason}

getStatusCodeReason

nodiscard

[[nodiscard]] const char * getStatusCodeReason(StatusCode status)

Returns the standard reason phrase for the given HTTP status code (e.g. "OK" for StatusCode::OK, "Not Found" for StatusCode::NotFound).

Parameters

  • status HTTP status code.

Returns

Null-terminated reason phrase string.


{#getstatuscodestring}

getStatusCodeString

nodiscard

[[nodiscard]] const char * getStatusCodeString(StatusCode status)

Returns a combined "NNN Reason" string for the given HTTP status code (e.g. "200 OK").

Parameters

  • status HTTP status code.

Returns

Null-terminated status code string.


{#statstaticfile}

statStaticFile

bool statStaticFile(std::string_view path, StaticFileInfo & info)

Read static-file metadata from disk.

Parameters

  • path File path on disk.

  • info Receives the file size, weak ETag, and HTTP-normalized last-modified time.

Returns

True if the path exists and is a regular file.


{#preparestaticfileresponse}

prepareStaticFileResponse

bool prepareStaticFileResponse(const Request & request, Response & response, const StaticFileInfo & info)

Apply static-file headers and request conditionals to the response.

Sets Content-Length, ETag, and Last-Modified from info, then evaluates If-None-Match and If-Modified-Since for the current request.

Parameters

  • request Incoming HTTP request.

  • response Outgoing HTTP response to update.

  • info Precomputed static-file metadata.

Returns

True if the response should not send a body (304 or 412).


{#parseuri}

parseURI

std::string parseURI(std::string_view request)

Extracts the URI (path and query) from a raw HTTP request line.

Parameters

  • request Raw HTTP request line (e.g. "GET /path?q=1 HTTP/1.1").

Returns

The URI portion (e.g. "/path?q=1").


{#matchurl}

matchURL

bool matchURL(std::string_view uri, std::string_view expression)

Tests whether a URI matches a glob-style expression.

Parameters

  • uri The URI to test.

  • expression Pattern to match against. '*' matches any sequence of characters.

Returns

true if the URI matches the expression.


{#parsecookieitem}

parseCookieItem

std::string parseCookieItem(std::string_view cookie, std::string_view item)

Extracts a named attribute from a Cookie header value.

Parameters

  • cookie Full Cookie header value (e.g. "name=value; Path=/; HttpOnly").

  • item Attribute name to find (e.g. "Path").

Returns

The value of the named attribute, or an empty string if not found.


{#splituriparameters}

splitURIParameters

bool splitURIParameters(std::string_view uri, NVCollection & out)

Parses URL query parameters from a URI into key-value pairs. Handles percent-decoding of names and values.

Parameters

  • uri URI string optionally containing a '?' query component.

  • out Collection to populate with parsed parameters.

Returns

true if at least one parameter was parsed; false otherwise.


{#splitparameters}

splitParameters

void splitParameters(const std::string & s, std::string & value, NVCollection & parameters)

Splits a header-style parameter string into a primary value and named attributes. Attributes are separated by ';'. Enclosing quotes are stripped from values.

Example input: "multipart/mixed; boundary="boundary-01234567"" Output value: "multipart/mixed", parameters: { "boundary" -> "boundary-01234567" }

Parameters

  • s Input string to split.

  • value Receives the primary value before the first ';'.

  • parameters Receives the parsed attribute key-value pairs.


{#splitparameters-1}

splitParameters

void splitParameters(const std::string::const_iterator & begin, const std::string::const_iterator & end, NVCollection & parameters)

Splits a substring (defined by iterators) into named attributes. Attributes are separated by ';'. Enclosing quotes are stripped from values.

Parameters

  • begin Iterator to the start of the string to parse.

  • end Iterator past the end of the string to parse.

  • parameters Receives the parsed attribute key-value pairs.

{#authenticator}

Authenticator

#include <icy/http/authenticator.h>
class Authenticator

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

Maintains HTTP Basic or Digest authentication state for outbound requests.

Note: Do not forget to read the entire response stream from the 401 response before sending the authenticated request, otherwise there may be problems if a persistent connection is used.

List of all members

NameKindOwner
AuthenticatorfunctionDeclared here
AuthenticatorfunctionDeclared here
~AuthenticatorfunctionDeclared here
fromUserInfofunctionDeclared here
fromURIfunctionDeclared here
setUsernamefunctionDeclared here
usernamefunctionDeclared here
setPasswordfunctionDeclared here
passwordfunctionDeclared here
authenticatefunctionDeclared here
updateAuthInfofunctionDeclared here
proxyAuthenticatefunctionDeclared here
updateProxyAuthInfofunctionDeclared here
_usernamevariableDeclared here
_passwordvariableDeclared here
AuthenticatorfunctionDeclared here

Public Methods

ReturnNameDescription
AuthenticatorCreates an empty authenticator.
AuthenticatorCreates an authenticator with the given username and password.
~AuthenticatorDestroys the authenticator.
voidfromUserInfoParses username:password std::string and sets username and password of the credentials object. Throws SyntaxException on invalid user information.
voidfromURIExtracts username and password from the given URI and sets username and password of the credentials object. Does nothing if URI has no user info part.
voidsetUsernameSets the username.
const std::string &username const nodiscardReturns the username.
voidsetPasswordSets the password.
const std::string &password const nodiscardReturns the password.
voidauthenticateInspects WWW-Authenticate header of the response, initializes the internal state (in case of digest authentication) and adds required information to the given http::Request.
voidupdateAuthInfoUpdates internal state (in case of digest authentication) and replaces authentication information in the request accordingly.
voidproxyAuthenticateInspects Proxy-Authenticate header of the response, initializes the internal state (in case of digest authentication) and adds required information to the given http::Request.
voidupdateProxyAuthInfoUpdates internal state (in case of digest authentication) and replaces proxy authentication information in the request accordingly.

{#authenticator-1}

Authenticator

Authenticator()

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

Creates an empty authenticator.


{#authenticator-2}

Authenticator

Authenticator(const std::string & username, const std::string & password)

Defined in src/http/include/icy/http/authenticator.h:39

Creates an authenticator with the given username and password.


{#authenticator-3}

~Authenticator

~Authenticator()

Defined in src/http/include/icy/http/authenticator.h:42

Destroys the authenticator.


{#fromuserinfo}

fromUserInfo

void fromUserInfo(std::string_view userInfo)

Defined in src/http/include/icy/http/authenticator.h:47

Parses username:password std::string and sets username and password of the credentials object. Throws SyntaxException on invalid user information.


{#fromuri}

fromURI

void fromURI(const http::URL & uri)

Defined in src/http/include/icy/http/authenticator.h:52

Extracts username and password from the given URI and sets username and password of the credentials object. Does nothing if URI has no user info part.


{#setusername}

setUsername

void setUsername(const std::string & username)

Defined in src/http/include/icy/http/authenticator.h:55

Sets the username.


{#username}

username

const nodiscard

[[nodiscard]] const std::string & username() const

Defined in src/http/include/icy/http/authenticator.h:58

Returns the username.


{#setpassword}

setPassword

void setPassword(const std::string & password)

Defined in src/http/include/icy/http/authenticator.h:61

Sets the password.


{#password}

password

const nodiscard

[[nodiscard]] const std::string & password() const

Defined in src/http/include/icy/http/authenticator.h:64

Returns the password.


{#authenticate}

authenticate

void authenticate(http::Request & request, const http::Response & response)

Defined in src/http/include/icy/http/authenticator.h:69

Inspects WWW-Authenticate header of the response, initializes the internal state (in case of digest authentication) and adds required information to the given http::Request.


{#updateauthinfo}

updateAuthInfo

void updateAuthInfo(http::Request & request)

Defined in src/http/include/icy/http/authenticator.h:73

Updates internal state (in case of digest authentication) and replaces authentication information in the request accordingly.


{#proxyauthenticate}

proxyAuthenticate

void proxyAuthenticate(http::Request & request, const http::Response & response)

Defined in src/http/include/icy/http/authenticator.h:78

Inspects Proxy-Authenticate header of the response, initializes the internal state (in case of digest authentication) and adds required information to the given http::Request.


{#updateproxyauthinfo}

updateProxyAuthInfo

void updateProxyAuthInfo(http::Request & request)

Defined in src/http/include/icy/http/authenticator.h:83

Updates internal state (in case of digest authentication) and replaces proxy authentication information in the request accordingly.

Private Attributes

ReturnNameDescription
std::string_username
std::string_password

{#_username}

_username

std::string _username

Defined in src/http/include/icy/http/authenticator.h:89


{#_password}

_password

std::string _password

Defined in src/http/include/icy/http/authenticator.h:90

Private Methods

ReturnNameDescription
AuthenticatorDeleted constructor.

{#authenticator-4}

Authenticator

Authenticator(const Authenticator &) = delete

Defined in src/http/include/icy/http/authenticator.h:86

Deleted constructor.

{#basicauthenticator}

BasicAuthenticator

#include <icy/http/authenticator.h>
class BasicAuthenticator

Defined in src/http/include/icy/http/authenticator.h:99

Encodes and decodes HTTP Basic authentication credentials.

List of all members

NameKindOwner
BasicAuthenticatorfunctionDeclared here
BasicAuthenticatorfunctionDeclared here
BasicAuthenticatorfunctionDeclared here
BasicAuthenticatorfunctionDeclared here
~BasicAuthenticatorfunctionDeclared here
setUsernamefunctionDeclared here
usernamefunctionDeclared here
setPasswordfunctionDeclared here
passwordfunctionDeclared here
authenticatefunctionDeclared here
proxyAuthenticatefunctionDeclared here
parseAuthInfofunctionDeclared here
_usernamevariableDeclared here
_passwordvariableDeclared here
BasicAuthenticatorfunctionDeclared here

Public Methods

ReturnNameDescription
BasicAuthenticatorCreates an empty basic authenticator.
BasicAuthenticatorCreates a basic authenticator with the given username and password.
BasicAuthenticator explicitExtracts basic authentication credentials from the given request.
BasicAuthenticator explicitParses a raw Basic authentication payload string. The value can be extracted from a request via [Request::getCredentials()](#getcredentials).
~BasicAuthenticatorDestroys the basic authenticator.
voidsetUsernameSets the username.
const std::string &username const nodiscardReturns the username.
voidsetPasswordSets the password.
const std::string &password const nodiscardReturns the password.
voidauthenticate constAdds authentication information to the given http::Request.
voidproxyAuthenticate constAdds proxy authentication information to the given http::Request.

{#basicauthenticator-1}

BasicAuthenticator

BasicAuthenticator()

Defined in src/http/include/icy/http/authenticator.h:103

Creates an empty basic authenticator.


{#basicauthenticator-2}

BasicAuthenticator

BasicAuthenticator(const std::string & username, const std::string & password)

Defined in src/http/include/icy/http/authenticator.h:106

Creates a basic authenticator with the given username and password.


{#basicauthenticator-3}

BasicAuthenticator

explicit

explicit BasicAuthenticator(const http::Request & request)

Defined in src/http/include/icy/http/authenticator.h:113

Extracts basic authentication credentials from the given request.

Throws a NotAuthenticatedException if the request does not contain basic authentication information.


{#basicauthenticator-4}

BasicAuthenticator

explicit

explicit BasicAuthenticator(const std::string & authInfo)

Defined in src/http/include/icy/http/authenticator.h:117

Parses a raw Basic authentication payload string. The value can be extracted from a request via [Request::getCredentials()](#getcredentials).


{#basicauthenticator-5}

~BasicAuthenticator

~BasicAuthenticator()

Defined in src/http/include/icy/http/authenticator.h:120

Destroys the basic authenticator.


{#setusername-1}

setUsername

void setUsername(const std::string & username)

Defined in src/http/include/icy/http/authenticator.h:123

Sets the username.


{#username-1}

username

const nodiscard

[[nodiscard]] const std::string & username() const

Defined in src/http/include/icy/http/authenticator.h:126

Returns the username.


{#setpassword-1}

setPassword

void setPassword(const std::string & password)

Defined in src/http/include/icy/http/authenticator.h:129

Sets the password.


{#password-1}

password

const nodiscard

[[nodiscard]] const std::string & password() const

Defined in src/http/include/icy/http/authenticator.h:132

Returns the password.


{#authenticate-1}

authenticate

const

void authenticate(http::Request & request) const

Defined in src/http/include/icy/http/authenticator.h:135

Adds authentication information to the given http::Request.


{#proxyauthenticate-1}

proxyAuthenticate

const

void proxyAuthenticate(http::Request & request) const

Defined in src/http/include/icy/http/authenticator.h:138

Adds proxy authentication information to the given http::Request.

Protected Methods

ReturnNameDescription
voidparseAuthInfoExtracts username and password from Basic authentication info by base64-decoding authInfo and splitting the resulting std::string at the ':' delimiter.

{#parseauthinfo}

parseAuthInfo

void parseAuthInfo(std::string_view authInfo)

Defined in src/http/include/icy/http/authenticator.h:144

Extracts username and password from Basic authentication info by base64-decoding authInfo and splitting the resulting std::string at the ':' delimiter.

Private Attributes

ReturnNameDescription
std::string_username
std::string_password

{#_username-1}

_username

std::string _username

Defined in src/http/include/icy/http/authenticator.h:150


{#_password-1}

_password

std::string _password

Defined in src/http/include/icy/http/authenticator.h:151

Private Methods

ReturnNameDescription
BasicAuthenticatorDeleted constructor.

{#basicauthenticator-6}

BasicAuthenticator

BasicAuthenticator(const BasicAuthenticator &) = delete

Defined in src/http/include/icy/http/authenticator.h:147

Deleted constructor.

{#chunkedadapter}

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
emitHeaderfunctionDeclared here
processfunctionDeclared here
PacketProcessorfunctionInherited from PacketProcessor
processfunctionInherited from PacketProcessor
acceptsfunctionInherited from PacketProcessor
operator<<functionInherited from PacketProcessor
_emittervariableInherited from PacketStreamAdapter
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
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
variable_emitter
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 const nodiscardReturns 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.
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

Connection::Ptr connection

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

HTTP connection to send the initial response header through.


{#contenttype}

contentType

std::string contentType

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

Content-Type value for the chunked response.


{#frameseparator}

frameSeparator

std::string frameSeparator

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

Optional separator written before each chunk payload.


{#initial}

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}

nocopy

bool nocopy

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

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


{#emitter-5}

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-1}

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-2}

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}

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-5}

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

{#client}

Client

#include <icy/http/client.h>
class Client

Defined in src/http/include/icy/http/client.h:192

HTTP client for creating and managing outgoing connections.

List of all members

NameKindOwner
ClientConnectionfriendDeclared here
ShutdownvariableDeclared here
ClientfunctionDeclared here
stopfunctionDeclared here
createConnectionTfunctionDeclared here
createConnectionfunctionDeclared here
addConnectionfunctionDeclared here
removeConnectionfunctionDeclared here
instancefunctionDeclared here
destroyfunctionDeclared here
_connectionsvariableDeclared here
onConnectionClosefunctionDeclared here

Friends

NameDescription
ClientConnection

{#clientconnection}

ClientConnection

friend class ClientConnection

Defined in src/http/include/icy/http/client.h:252

Public Attributes

ReturnNameDescription
NullSignalShutdown

{#shutdown-6}

Shutdown

NullSignal Shutdown

Defined in src/http/include/icy/http/client.h:247

Public Methods

ReturnNameDescription
Client
voidstopStop the Client and close all connections.
ClientConnection::PtrcreateConnectionT inlineCreates and registers a typed client connection for the given URL. The connection type is inferred from the URL scheme (http, https, ws, wss).
ClientConnection::PtrcreateConnection inlineCreates and registers a ClientConnection for the given URL. The socket type is chosen based on the URL scheme (http/https/ws/wss).
voidaddConnection virtualRegisters a connection with this client so it is tracked and cleaned up on stop().
voidremoveConnection virtualRemoves a previously registered connection from the client.

{#client-1}

Client

Client()

Defined in src/http/include/icy/http/client.h:195


{#stop-7}

stop

void stop()

Defined in src/http/include/icy/http/client.h:205

Stop the Client and close all connections.


{#createconnectiont-1}

createConnectionT

inline

template<class ConnectionT> inline ClientConnection::Ptr createConnectionT(const URL & url, uv::Loop * loop = uv::defaultLoop())

Defined in src/http/include/icy/http/client.h:215

Creates and registers a typed client connection for the given URL. The connection type is inferred from the URL scheme (http, https, ws, wss).

Parameters

Parameters

  • url Target URL. The scheme determines the socket and adapter type.

  • loop Event loop to use. Defaults to the default libuv loop.

Returns

Shared pointer to the created connection.


{#createconnection-1}

createConnection

inline

inline ClientConnection::Ptr createConnection(const URL & url, uv::Loop * loop = uv::defaultLoop())

Defined in src/http/include/icy/http/client.h:229

Creates and registers a ClientConnection for the given URL. The socket type is chosen based on the URL scheme (http/https/ws/wss).

Parameters

  • url Target URL.

  • loop Event loop to use. Defaults to the default libuv loop.

Returns

Shared pointer to the created connection.


{#addconnection}

addConnection

virtual

virtual void addConnection(ClientConnection::Ptr conn)

Defined in src/http/include/icy/http/client.h:240

Registers a connection with this client so it is tracked and cleaned up on stop().

Parameters

  • conn The connection to add.

{#removeconnection}

removeConnection

virtual

virtual void removeConnection(ClientConnection * conn)

Defined in src/http/include/icy/http/client.h:245

Removes a previously registered connection from the client.

Parameters

  • conn Raw pointer to the connection to remove.

Exceptions

  • std::logic_error if the connection is not tracked by this client.

Public Static Methods

ReturnNameDescription
Client &instance staticReturn the default HTTP Client singleton.
voiddestroy staticDestroys the default HTTP Client singleton.

{#instance-3}

instance

static

static Client & instance()

Defined in src/http/include/icy/http/client.h:199

Return the default HTTP Client singleton.


{#destroy-1}

destroy

static

static void destroy()

Defined in src/http/include/icy/http/client.h:202

Destroys the default HTTP Client singleton.

Protected Attributes

ReturnNameDescription
ClientConnectionPtrVec_connections

{#_connections}

_connections

ClientConnectionPtrVec _connections

Defined in src/http/include/icy/http/client.h:254

Protected Methods

ReturnNameDescription
voidonConnectionClose

{#onconnectionclose}

onConnectionClose

void onConnectionClose(Connection & conn)

Defined in src/http/include/icy/http/client.h:250

{#clientconnection-1}

ClientConnection

#include <icy/http/client.h>
class ClientConnection

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

Inherits: Connection

HTTP client connection for managing request/response lifecycle.

List of all members

NameKindOwner
opaquevariableDeclared here
ConnectvariableDeclared here
HeadersvariableDeclared here
PayloadvariableDeclared here
CompletevariableDeclared here
ErrorvariableDeclared here
ClosevariableDeclared here
IncomingProgressvariableDeclared here
ClientConnectionfunctionDeclared here
startfunctionDeclared here
startfunctionDeclared here
sendfunctionDeclared here
setReadStreamfunctionDeclared here
readStreamfunctionDeclared here
_urlvariableDeclared here
_connectvariableDeclared here
_activevariableDeclared here
_completevariableDeclared here
_outgoingBuffervariableDeclared here
_readStreamvariableDeclared here
connectfunctionDeclared here
incomingHeaderfunctionDeclared here
outgoingHeaderfunctionDeclared here
onSocketConnectfunctionDeclared here
PtrtypedefDeclared here
onHeadersfunctionDeclared here
onPayloadfunctionDeclared here
onCompletefunctionDeclared here
onClosefunctionDeclared here
onSocketErrorfunctionDeclared here
ConnectionStreamfriendInherited from Connection
ConnectionAdapterfriendInherited from Connection
ConnectionfunctionInherited from Connection
onHeadersfunctionInherited from Connection
onPayloadfunctionInherited from Connection
onCompletefunctionInherited from Connection
onClosefunctionInherited from Connection
sendfunctionInherited from Connection
sendOwnedfunctionInherited from Connection
sendHeaderfunctionInherited from Connection
closefunctionInherited from Connection
markActivefunctionInherited from Connection
beginStreamingfunctionInherited from Connection
endStreamingfunctionInherited from Connection
closedfunctionInherited from Connection
errorfunctionInherited from Connection
headerAutoSendEnabledfunctionInherited from Connection
setHeaderAutoSendEnabledfunctionInherited from Connection
replaceAdapterfunctionInherited from Connection
replaceAdapterfunctionInherited from Connection
securefunctionInherited from Connection
socketfunctionInherited from Connection
adapterfunctionInherited from Connection
requestfunctionInherited from Connection
responsefunctionInherited from Connection
incomingHeaderfunctionInherited from Connection
outgoingHeaderfunctionInherited from Connection
_socketvariableInherited from Connection
_adaptervariableInherited from Connection
_requestvariableInherited from Connection
_responsevariableInherited from Connection
_errorvariableInherited from Connection
_closedvariableInherited from Connection
_shouldSendHeadervariableInherited from Connection
setErrorfunctionInherited from Connection
onSocketConnectfunctionInherited from Connection
onSocketRecvfunctionInherited from Connection
onSocketErrorfunctionInherited from Connection
onSocketClosefunctionInherited from Connection
PtrtypedefInherited from Connection
priorityvariableInherited from SocketAdapter
SocketAdapterfunctionInherited from SocketAdapter
~SocketAdapterfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
setSenderfunctionInherited from SocketAdapter
senderfunctionInherited from SocketAdapter
addReceiverfunctionInherited from SocketAdapter
removeReceiverfunctionInherited from SocketAdapter
hasReceiverfunctionInherited from SocketAdapter
receiversfunctionInherited from SocketAdapter
onSocketConnectfunctionInherited from SocketAdapter
onSocketRecvfunctionInherited from SocketAdapter
onSocketErrorfunctionInherited from SocketAdapter
onSocketClosefunctionInherited from SocketAdapter
_sendervariableInherited from SocketAdapter
_receiversvariableInherited from SocketAdapter
_dirtyvariableInherited from SocketAdapter
cleanupReceiversfunctionInherited from SocketAdapter

Inherited from Connection

KindNameDescription
friendConnectionStream
friendConnectionAdapter
functionConnectionCreates a Connection using the given TCP socket.
functiononHeaders virtualCalled when the incoming HTTP headers have been fully parsed.
functiononPayload virtualCalled for each chunk of incoming body data after headers are complete.
functiononComplete virtualCalled when the incoming HTTP message is fully received.
functiononClose virtualCalled when the connection is closed.
functionsend virtual overrideSend raw data to the peer.
functionsendOwned virtual overrideSend an owned payload buffer to the peer.
functionsendHeader virtualSend the outdoing HTTP header.
functionclose virtualClose the connection and schedule the object for deferred deletion.
functionmarkActive virtual inlineMarks the connection as active. Server connections override this to refresh the idle timer.
functionbeginStreaming virtual inlineExplicitly 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.
functionendStreaming virtual inlineExit long-lived streaming mode.
functionclosed const nodiscardReturn true if the connection is closed.
functionerror const nodiscardReturn the error object if any.
functionheaderAutoSendEnabled const nodiscardReturn true if headers should be automatically sent.
functionsetHeaderAutoSendEnabledEnable or disable automatic header emission for the next outgoing send path.
functionreplaceAdapter virtualAssign the new ConnectionAdapter and setup the chain. The flow is: Connection <-> ConnectionAdapter <-> Socket. Takes ownership of the adapter (deferred deletion via uv loop).
functionreplaceAdapter virtualOverload for nullptr (used in destructor to clear adapter).
functionsecure const nodiscardReturn true if the connection uses TLS/SSL.
functionsocket nodiscardReturn the underlying socket pointer.
functionadapter const nodiscardReturn the underlying adapter pointer.
functionrequest nodiscardThe HTTP request headers.
functionresponse nodiscardThe HTTP response headers.
functionincomingHeader virtualReturns the incoming HTTP message header (request or response depending on role).
functionoutgoingHeader virtualReturns 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
functionsetError virtualSet the internal error. Note: Setting the error does not [close()](#close-20) the connection.
functiononSocketConnect virtual overridenet::SocketAdapter interface
functiononSocketRecv virtual overrideCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtual overrideCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtual overrideCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
typedefPtr

Inherited from SocketAdapter

KindNameDescription
variablepriorityThe priority of this adapter for STL sort operations.
functionSocketAdapterCreates the SocketAdapter.
function~SocketAdapter virtual noexceptDestroys the SocketAdapter.
functionsend virtual nodiscardSends 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.
functionsend virtual nodiscard
functionsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
functionsendOwned virtual nodiscard
functionsendPacket virtualSends 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.
functionsendPacket virtual
functionsendPacket virtualSends 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.
functionsetSender virtualSets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
functionsenderReturns the output SocketAdapter pointer.
functionaddReceiver virtualSets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
functionremoveReceiver virtualRemove the given receiver.
functionhasReceiver virtualReturns true if the given receiver is connected.
functionreceiversReturns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
functiononSocketConnect virtualCalled 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.
functiononSocketRecv virtualCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtualCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtualCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
variable_sender
variable_receivers
variable_dirty
functioncleanupReceivers virtual

Public Attributes

ReturnNameDescription
void *opaqueOptional unmanaged client data pointer. Not used by the connection internally.
NullSignalConnectStatus signals.
Signal< void(Response &)>HeadersSignals when the response HTTP header has been received.
Signal< void(const MutableBuffer &)>PayloadSignals when raw data is received.
Signal< void(const Response &)>CompleteSignals when the HTTP transaction is complete.
Signal< void(const icy::Error &)>ErrorSignals when the underlying transport reports an error.
Signal< void(Connection &)>CloseSignals when the connection is closed.
ProgressSignalIncomingProgressSignals download progress (0-100%).

{#opaque-1}

opaque

void * opaque

Defined in src/http/include/icy/http/client.h:91

Optional unmanaged client data pointer. Not used by the connection internally.


{#connect-11}

Connect

NullSignal Connect

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

Status signals.

Signals when the client socket is connected and data can flow


{#headers}

Headers

Signal< void(Response &)> Headers

Defined in src/http/include/icy/http/client.h:111

Signals when the response HTTP header has been received.


{#payload}

Payload

Signal< void(const MutableBuffer &)> Payload

Defined in src/http/include/icy/http/client.h:112

Signals when raw data is received.


{#complete}

Complete

Signal< void(const Response &)> Complete

Defined in src/http/include/icy/http/client.h:113

Signals when the HTTP transaction is complete.


{#error-9}

Error

Signal< void(const icy::Error &)> Error

Defined in src/http/include/icy/http/client.h:114

Signals when the underlying transport reports an error.


{#close-19}

Close

Signal< void(Connection &)> Close

Defined in src/http/include/icy/http/client.h:115

Signals when the connection is closed.


{#incomingprogress}

IncomingProgress

ProgressSignal IncomingProgress

Defined in src/http/include/icy/http/client.h:116

Signals download progress (0-100%).

Public Methods

ReturnNameDescription
ClientConnectionCreates a ClientConnection to the given URL, pre-populating the request URI and Host header. The response status is initialised to 502 Bad Gateway until a real response is received.
voidstart virtualStarts the internal HTTP request.
voidstart virtualStarts the given HTTP request, replacing the internal request object.
ssize_tsend virtual overrideSends raw data to the peer, initiating a connection first if needed. Data is buffered internally until the connection is established.
voidsetReadStream virtualSets the output stream to which incoming response body data is written. The stream pointer is owned by the connection and freed with it. Must be called before start().
StreamT &readStream inlineReturns a reference to the read stream cast to the specified type.

{#clientconnection-2}

ClientConnection

ClientConnection(const URL & url, const net::TCPSocket::Ptr & socket = std::make_shared< net::TCPSocket >())

Defined in src/http/include/icy/http/client.h:42

Creates a ClientConnection to the given URL, pre-populating the request URI and Host header. The response status is initialised to 502 Bad Gateway until a real response is received.

Parameters

  • url Target URL. Scheme, host, port and path are extracted automatically.

  • socket TCP socket to use. Defaults to a plain TCPSocket; pass an SSLSocket for HTTPS.


{#start-8}

start

virtual

virtual void start()

Defined in src/http/include/icy/http/client.h:51

Starts the internal HTTP request.

Calls connect() internally if the socket is not already connecting or connected. The actual request will be sent when the socket is connected.

Exceptions

  • std::runtime_error if already connecting.

{#start-9}

start

virtual

virtual void start(http::Request & req)

Defined in src/http/include/icy/http/client.h:59

Starts the given HTTP request, replacing the internal request object.

Calls connect() internally if the socket is not already connecting or connected. The actual request will be sent when the socket is connected.

Parameters

  • req The HTTP request to send. Replaces the internal request.

Exceptions

  • std::runtime_error if already connecting.

{#send-10}

send

virtual override

virtual ssize_t send(const char * data, size_t len, int flags = 0) override

Defined in src/http/include/icy/http/client.h:67

Sends raw data to the peer, initiating a connection first if needed. Data is buffered internally until the connection is established.

Parameters

  • data Pointer to the data buffer.

  • len Number of bytes to send.

  • flags Socket send flags (unused for HTTP).

Returns

Number of bytes sent or buffered.

Reimplements

{#setreadstream}

setReadStream

virtual

virtual void setReadStream(std::ostream * os)

Defined in src/http/include/icy/http/client.h:74

Sets the output stream to which incoming response body data is written. The stream pointer is owned by the connection and freed with it. Must be called before start().

Parameters

  • os Pointer to the output stream. Takes ownership.

Exceptions

  • std::runtime_error if already connecting.

{#readstream}

readStream

inline

template<class StreamT> inline StreamT & readStream()

Defined in src/http/include/icy/http/client.h:82

Returns a reference to the read stream cast to the specified type.

Parameters

  • StreamT The concrete stream type to cast to.

Returns

Reference to the stream.

Exceptions

  • std::runtime_error if no read stream has been set.

  • std::bad_cast if the stream is not of type StreamT.

Protected Attributes

ReturnNameDescription
URL_url
bool_connect
bool_active
bool_complete
std::vector< PendingWrite >_outgoingBuffer
std::unique_ptr< std::ostream >_readStream

{#_url}

_url

URL _url

Defined in src/http/include/icy/http/client.h:135


{#_connect}

_connect

bool _connect

Defined in src/http/include/icy/http/client.h:136


{#_active}

_active

bool _active

Defined in src/http/include/icy/http/client.h:137


{#_complete}

_complete

bool _complete

Defined in src/http/include/icy/http/client.h:138


{#_outgoingbuffer}

_outgoingBuffer

std::vector< PendingWrite > _outgoingBuffer

Defined in src/http/include/icy/http/client.h:139


{#_readstream}

_readStream

std::unique_ptr< std::ostream > _readStream

Defined in src/http/include/icy/http/client.h:140

Protected Methods

ReturnNameDescription
voidconnect virtualConnects to the server endpoint. All sent data is buffered until the connection is made.
http::Message *incomingHeader virtual overrideReturns the incoming HTTP message header (request or response depending on role).
http::Message *outgoingHeader virtual overrideReturns the outgoing HTTP message header (request or response depending on role).
boolonSocketConnect virtual overridenet::SocketAdapter interface

{#connect-12}

connect

virtual

virtual void connect()

Defined in src/http/include/icy/http/client.h:121

Connects to the server endpoint. All sent data is buffered until the connection is made.


{#incomingheader}

incomingHeader

virtual override

virtual http::Message * incomingHeader() override

Defined in src/http/include/icy/http/client.h:123

Returns the incoming HTTP message header (request or response depending on role).

Reimplements

{#outgoingheader}

outgoingHeader

virtual override

virtual http::Message * outgoingHeader() override

Defined in src/http/include/icy/http/client.h:124

Returns the outgoing HTTP message header (request or response depending on role).

Reimplements

{#onsocketconnect-2}

onSocketConnect

virtual override

virtual bool onSocketConnect(net::Socket & socket) override

Defined in src/http/include/icy/http/client.h:126

net::SocketAdapter interface

Reimplements

Public Types

NameDescription
Ptr

{#ptr-11}

Ptr

using Ptr = std::shared_ptr< ClientConnection >

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

Private Methods

ReturnNameDescription
voidonHeaders virtual overrideConnection interface.
voidonPayload virtual overrideCalled for each chunk of incoming response body data.
voidonComplete virtual overrideCalled when the full HTTP response has been received.
voidonClose virtual overrideCalled when the connection is closed.
boolonSocketError virtual overrideCalled when the underlying transport encounters an error.

{#onheaders}

onHeaders

virtual override

virtual void onHeaders() override

Defined in src/http/include/icy/http/client.h:97

Connection interface.

Called when the response headers have been parsed.

Reimplements

{#onpayload}

onPayload

virtual override

virtual void onPayload(const MutableBuffer & buffer) override

Defined in src/http/include/icy/http/client.h:99

Called for each chunk of incoming response body data.

Reimplements

{#oncomplete}

onComplete

virtual override

virtual void onComplete() override

Defined in src/http/include/icy/http/client.h:101

Called when the full HTTP response has been received.

Reimplements

{#onclose-3}

onClose

virtual override

virtual void onClose() override

Defined in src/http/include/icy/http/client.h:103

Called when the connection is closed.

Reimplements

{#onsocketerror-2}

onSocketError

virtual override

virtual bool onSocketError(net::Socket & socket, const icy::Error & error) override

Defined in src/http/include/icy/http/client.h:105

Called when the underlying transport encounters an error.

Reimplements

{#pendingwrite}

PendingWrite

#include <icy/http/client.h>
struct PendingWrite

Defined in src/http/include/icy/http/client.h:129

List of all members

NameKindOwner
datavariableDeclared here
flagsvariableDeclared here

Public Attributes

ReturnNameDescription
Bufferdata
intflags

{#data-1}

data

Buffer data

Defined in src/http/include/icy/http/client.h:131


{#flags}

flags

int flags = 0

Defined in src/http/include/icy/http/client.h:132

{#connection-1}

Connection

#include <icy/http/connection.h>
class Connection

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

Inherits: SocketAdapter Subclassed by: ClientConnection, ServerConnection

Base HTTP connection managing socket I/O and message lifecycle

List of all members

NameKindOwner
ConnectionStreamfriendDeclared here
ConnectionAdapterfriendDeclared here
ConnectionfunctionDeclared here
onHeadersfunctionDeclared here
onPayloadfunctionDeclared here
onCompletefunctionDeclared here
onClosefunctionDeclared here
sendfunctionDeclared here
sendOwnedfunctionDeclared here
sendHeaderfunctionDeclared here
closefunctionDeclared here
markActivefunctionDeclared here
beginStreamingfunctionDeclared here
endStreamingfunctionDeclared here
closedfunctionDeclared here
errorfunctionDeclared here
headerAutoSendEnabledfunctionDeclared here
setHeaderAutoSendEnabledfunctionDeclared here
replaceAdapterfunctionDeclared here
replaceAdapterfunctionDeclared here
securefunctionDeclared here
socketfunctionDeclared here
adapterfunctionDeclared here
requestfunctionDeclared here
responsefunctionDeclared here
incomingHeaderfunctionDeclared here
outgoingHeaderfunctionDeclared here
_socketvariableDeclared here
_adaptervariableDeclared here
_requestvariableDeclared here
_responsevariableDeclared here
_errorvariableDeclared here
_closedvariableDeclared here
_shouldSendHeadervariableDeclared here
setErrorfunctionDeclared here
onSocketConnectfunctionDeclared here
onSocketRecvfunctionDeclared here
onSocketErrorfunctionDeclared here
onSocketClosefunctionDeclared here
PtrtypedefDeclared here
priorityvariableInherited from SocketAdapter
SocketAdapterfunctionInherited from SocketAdapter
~SocketAdapterfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
setSenderfunctionInherited from SocketAdapter
senderfunctionInherited from SocketAdapter
addReceiverfunctionInherited from SocketAdapter
removeReceiverfunctionInherited from SocketAdapter
hasReceiverfunctionInherited from SocketAdapter
receiversfunctionInherited from SocketAdapter
onSocketConnectfunctionInherited from SocketAdapter
onSocketRecvfunctionInherited from SocketAdapter
onSocketErrorfunctionInherited from SocketAdapter
onSocketClosefunctionInherited from SocketAdapter
_sendervariableInherited from SocketAdapter
_receiversvariableInherited from SocketAdapter
_dirtyvariableInherited from SocketAdapter
cleanupReceiversfunctionInherited from SocketAdapter

Inherited from SocketAdapter

KindNameDescription
variablepriorityThe priority of this adapter for STL sort operations.
functionSocketAdapterCreates the SocketAdapter.
function~SocketAdapter virtual noexceptDestroys the SocketAdapter.
functionsend virtual nodiscardSends 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.
functionsend virtual nodiscard
functionsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
functionsendOwned virtual nodiscard
functionsendPacket virtualSends 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.
functionsendPacket virtual
functionsendPacket virtualSends 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.
functionsetSender virtualSets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
functionsenderReturns the output SocketAdapter pointer.
functionaddReceiver virtualSets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
functionremoveReceiver virtualRemove the given receiver.
functionhasReceiver virtualReturns true if the given receiver is connected.
functionreceiversReturns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
functiononSocketConnect virtualCalled 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.
functiononSocketRecv virtualCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtualCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtualCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
variable_sender
variable_receivers
variable_dirty
functioncleanupReceivers virtual

Friends

NameDescription
ConnectionStream
ConnectionAdapter

{#connectionstream}

ConnectionStream

friend class ConnectionStream

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


{#connectionadapter}

ConnectionAdapter

friend class ConnectionAdapter

Defined in src/http/include/icy/http/connection.h:149

Public Methods

ReturnNameDescription
ConnectionCreates a Connection using the given TCP socket.
voidonHeaders virtualCalled when the incoming HTTP headers have been fully parsed.
voidonPayload virtualCalled for each chunk of incoming body data after headers are complete.
voidonComplete virtualCalled when the incoming HTTP message is fully received.
voidonClose virtualCalled when the connection is closed.
ssize_tsend virtual overrideSend raw data to the peer.
ssize_tsendOwned virtual overrideSend an owned payload buffer to the peer.
ssize_tsendHeader virtualSend the outdoing HTTP header.
voidclose virtualClose the connection and schedule the object for deferred deletion.
voidmarkActive virtual inlineMarks the connection as active. Server connections override this to refresh the idle timer.
voidbeginStreaming virtual inlineExplicitly 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.
voidendStreaming virtual inlineExit long-lived streaming mode.
boolclosed const nodiscardReturn true if the connection is closed.
icy::Errorerror const nodiscardReturn the error object if any.
boolheaderAutoSendEnabled const nodiscardReturn true if headers should be automatically sent.
voidsetHeaderAutoSendEnabledEnable or disable automatic header emission for the next outgoing send path.
voidreplaceAdapter virtualAssign the new ConnectionAdapter and setup the chain. The flow is: Connection <-> ConnectionAdapter <-> Socket. Takes ownership of the adapter (deferred deletion via uv loop).
voidreplaceAdapter virtualOverload for nullptr (used in destructor to clear adapter).
boolsecure const nodiscardReturn true if the connection uses TLS/SSL.
net::TCPSocket::Ptr &socket nodiscardReturn the underlying socket pointer.
net::SocketAdapter *adapter const nodiscardReturn the underlying adapter pointer.
Request &request nodiscardThe HTTP request headers.
Response &response nodiscardThe HTTP response headers.
http::Message *incomingHeader virtualReturns the incoming HTTP message header (request or response depending on role).
http::Message *outgoingHeader virtualReturns the outgoing HTTP message header (request or response depending on role).

{#connection-2}

Connection

Connection(const net::TCPSocket::Ptr & socket = std::make_shared< net::TCPSocket >())

Defined in src/http/include/icy/http/connection.h:41

Creates a Connection using the given TCP socket.

Parameters

  • socket The TCP socket to use for I/O. Defaults to a new TCPSocket.

{#onheaders-1}

onHeaders

virtual

virtual void onHeaders()

Defined in src/http/include/icy/http/connection.h:45

Called when the incoming HTTP headers have been fully parsed.

Reimplemented by

{#onpayload-1}

onPayload

virtual

virtual void onPayload(const MutableBuffer & buffer)

Defined in src/http/include/icy/http/connection.h:49

Called for each chunk of incoming body data after headers are complete.

Parameters

  • buffer Buffer containing the received data chunk.
Reimplemented by

{#oncomplete-1}

onComplete

virtual

virtual void onComplete()

Defined in src/http/include/icy/http/connection.h:52

Called when the incoming HTTP message is fully received.

Reimplemented by

{#onclose-4}

onClose

virtual

virtual void onClose()

Defined in src/http/include/icy/http/connection.h:55

Called when the connection is closed.

Reimplemented by

{#send-11}

send

virtual override

virtual ssize_t send(const char * data, size_t len, int flags = 0) override

Defined in src/http/include/icy/http/connection.h:61

Send raw data to the peer.

This is the zero-copy fast path. The caller retains ownership of the payload until the underlying async write completes.

Reimplements
Reimplemented by

{#sendowned-10}

sendOwned

virtual override

virtual ssize_t sendOwned(Buffer && buffer, int flags = 0) override

Defined in src/http/include/icy/http/connection.h:66

Send an owned payload buffer to the peer.

Use this when the payload does not naturally outlive the current scope.

Reimplements

{#sendheader}

sendHeader

virtual

virtual ssize_t sendHeader()

Defined in src/http/include/icy/http/connection.h:69

Send the outdoing HTTP header.

Reimplemented by

{#close-20}

close

virtual

virtual void close()

Defined in src/http/include/icy/http/connection.h:73

Close the connection and schedule the object for deferred deletion.

Reimplemented by

{#markactive}

markActive

virtual inline

virtual inline void markActive()

Defined in src/http/include/icy/http/connection.h:77

Marks the connection as active. Server connections override this to refresh the idle timer.

Reimplemented by

{#beginstreaming}

beginStreaming

virtual inline

virtual inline void beginStreaming()

Defined in src/http/include/icy/http/connection.h:82

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.

Reimplemented by

{#endstreaming}

endStreaming

virtual inline

virtual inline void endStreaming()

Defined in src/http/include/icy/http/connection.h:85

Exit long-lived streaming mode.

Reimplemented by

{#closed-4}

closed

const nodiscard

[[nodiscard]] bool closed() const

Defined in src/http/include/icy/http/connection.h:88

Return true if the connection is closed.


{#error-10}

error

const nodiscard

[[nodiscard]] icy::Error error() const

Defined in src/http/include/icy/http/connection.h:91

Return the error object if any.


{#headerautosendenabled}

headerAutoSendEnabled

const nodiscard

[[nodiscard]] bool headerAutoSendEnabled() const

Defined in src/http/include/icy/http/connection.h:94

Return true if headers should be automatically sent.


{#setheaderautosendenabled}

setHeaderAutoSendEnabled

void setHeaderAutoSendEnabled(bool enabled)

Defined in src/http/include/icy/http/connection.h:97

Enable or disable automatic header emission for the next outgoing send path.


{#replaceadapter}

replaceAdapter

virtual

virtual void replaceAdapter(std::unique_ptr< net::SocketAdapter > adapter)

Defined in src/http/include/icy/http/connection.h:102

Assign the new ConnectionAdapter and setup the chain. The flow is: Connection <-> ConnectionAdapter <-> Socket. Takes ownership of the adapter (deferred deletion via uv loop).


{#replaceadapter-1}

replaceAdapter

virtual

virtual void replaceAdapter(std::nullptr_t)

Defined in src/http/include/icy/http/connection.h:105

Overload for nullptr (used in destructor to clear adapter).


{#secure}

secure

const nodiscard

[[nodiscard]] bool secure() const

Defined in src/http/include/icy/http/connection.h:108

Return true if the connection uses TLS/SSL.


{#socket-5}

socket

nodiscard

[[nodiscard]] net::TCPSocket::Ptr & socket()

Defined in src/http/include/icy/http/connection.h:111

Return the underlying socket pointer.


{#adapter}

adapter

const nodiscard

[[nodiscard]] net::SocketAdapter * adapter() const

Defined in src/http/include/icy/http/connection.h:114

Return the underlying adapter pointer.


{#request-3}

request

nodiscard

[[nodiscard]] Request & request()

Defined in src/http/include/icy/http/connection.h:117

The HTTP request headers.


{#response}

response

nodiscard

[[nodiscard]] Response & response()

Defined in src/http/include/icy/http/connection.h:120

The HTTP response headers.


{#incomingheader-1}

incomingHeader

virtual

virtual http::Message * incomingHeader()

Defined in src/http/include/icy/http/connection.h:123

Returns the incoming HTTP message header (request or response depending on role).

Reimplemented by

{#outgoingheader-1}

outgoingHeader

virtual

virtual http::Message * outgoingHeader()

Defined in src/http/include/icy/http/connection.h:126

Returns the outgoing HTTP message header (request or response depending on role).

Reimplemented by

Protected Attributes

ReturnNameDescription
net::TCPSocket::Ptr_socket
net::SocketAdapter *_adapter
Request_request
Response_response
icy::Error_error
bool_closed
bool_shouldSendHeader

{#_socket-1}

_socket

net::TCPSocket::Ptr _socket

Defined in src/http/include/icy/http/connection.h:140


{#_adapter}

_adapter

net::SocketAdapter * _adapter

Defined in src/http/include/icy/http/connection.h:141


{#_request}

_request

Request _request

Defined in src/http/include/icy/http/connection.h:142


{#_response}

_response

Response _response

Defined in src/http/include/icy/http/connection.h:143


{#_error-2}

_error

icy::Error _error

Defined in src/http/include/icy/http/connection.h:144


{#_closed}

_closed

bool _closed

Defined in src/http/include/icy/http/connection.h:145


{#_shouldsendheader}

_shouldSendHeader

bool _shouldSendHeader

Defined in src/http/include/icy/http/connection.h:146

Protected Methods

ReturnNameDescription
voidsetError virtualSet the internal error. Note: Setting the error does not [close()](#close-20) the connection.
boolonSocketConnect virtual overridenet::SocketAdapter interface
boolonSocketRecv virtual overrideCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
boolonSocketError virtual overrideCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
boolonSocketClose virtual overrideCalled when the socket is closed. Forwards the event to all registered receivers in priority order.

{#seterror-4}

setError

virtual

virtual void setError(const icy::Error & err)

Defined in src/http/include/icy/http/connection.h:131

Set the internal error. Note: Setting the error does not [close()](#close-20) the connection.


{#onsocketconnect-3}

onSocketConnect

virtual override

virtual bool onSocketConnect(net::Socket & socket) override

Defined in src/http/include/icy/http/connection.h:134

net::SocketAdapter interface

Reimplements
Reimplemented by

{#onsocketrecv-3}

onSocketRecv

virtual override

virtual bool onSocketRecv(net::Socket & socket, const MutableBuffer & buffer, const net::Address & peerAddress) override

Defined in src/http/include/icy/http/connection.h:135

Called when data is received from the socket. Forwards the event to all registered receivers in priority order.

Parameters

  • socket The socket that received data.

  • buffer The received data buffer.

  • peerAddress Address of the sender.

Returns

true to stop propagation to subsequent receivers.

Reimplements

{#onsocketerror-3}

onSocketError

virtual override

virtual bool onSocketError(net::Socket & socket, const icy::Error & error) override

Defined in src/http/include/icy/http/connection.h:136

Called when the socket encounters an error. Forwards the event to all registered receivers in priority order.

Parameters

  • socket The socket that encountered the error.

  • error Error details.

Returns

true to stop propagation to subsequent receivers.

Reimplements
Reimplemented by

{#onsocketclose-2}

onSocketClose

virtual override

virtual bool onSocketClose(net::Socket & socket) override

Defined in src/http/include/icy/http/connection.h:137

Called when the socket is closed. Forwards the event to all registered receivers in priority order.

Parameters

  • socket The socket that was closed.

Returns

true to stop propagation to subsequent receivers.

Reimplements

Public Types

NameDescription
Ptr

{#ptr-12}

Ptr

using Ptr = std::shared_ptr< Connection >

Defined in src/http/include/icy/http/connection.h:37

{#connectionadapter-1}

ConnectionAdapter

#include <icy/http/connection.h>
class ConnectionAdapter

Defined 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

NameKindOwner
ConnectionAdapterfunctionDeclared here
sendfunctionDeclared here
sendOwnedfunctionDeclared here
removeReceiverfunctionDeclared here
parserfunctionDeclared here
connectionfunctionDeclared here
resetfunctionDeclared here
_connectionvariableDeclared here
_parservariableDeclared here
onSocketRecvfunctionDeclared here
onParserHeaderfunctionDeclared here
onParserHeadersEndfunctionDeclared here
onParserChunkfunctionDeclared here
onParserErrorfunctionDeclared here
onParserEndfunctionDeclared here
onParserHeaderfunctionInherited from ParserObserver
onParserHeadersEndfunctionInherited from ParserObserver
onParserChunkfunctionInherited from ParserObserver
onParserEndfunctionInherited from ParserObserver
onParserErrorfunctionInherited from ParserObserver
priorityvariableInherited from SocketAdapter
SocketAdapterfunctionInherited from SocketAdapter
~SocketAdapterfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
setSenderfunctionInherited from SocketAdapter
senderfunctionInherited from SocketAdapter
addReceiverfunctionInherited from SocketAdapter
removeReceiverfunctionInherited from SocketAdapter
hasReceiverfunctionInherited from SocketAdapter
receiversfunctionInherited from SocketAdapter
onSocketConnectfunctionInherited from SocketAdapter
onSocketRecvfunctionInherited from SocketAdapter
onSocketErrorfunctionInherited from SocketAdapter
onSocketClosefunctionInherited from SocketAdapter
_sendervariableInherited from SocketAdapter
_receiversvariableInherited from SocketAdapter
_dirtyvariableInherited from SocketAdapter
cleanupReceiversfunctionInherited from SocketAdapter

Inherited from ParserObserver

KindNameDescription
functiononParserHeader virtualCalled for each parsed HTTP header name/value pair.
functiononParserHeadersEnd virtualCalled when all HTTP headers have been parsed.
functiononParserChunk virtualCalled for each chunk of body data received.
functiononParserEnd virtualCalled when the HTTP message is fully parsed.
functiononParserError virtualCalled when a parse error occurs.

Inherited from SocketAdapter

KindNameDescription
variablepriorityThe priority of this adapter for STL sort operations.
functionSocketAdapterCreates the SocketAdapter.
function~SocketAdapter virtual noexceptDestroys the SocketAdapter.
functionsend virtual nodiscardSends 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.
functionsend virtual nodiscard
functionsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
functionsendOwned virtual nodiscard
functionsendPacket virtualSends 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.
functionsendPacket virtual
functionsendPacket virtualSends 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.
functionsetSender virtualSets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
functionsenderReturns the output SocketAdapter pointer.
functionaddReceiver virtualSets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
functionremoveReceiver virtualRemove the given receiver.
functionhasReceiver virtualReturns true if the given receiver is connected.
functionreceiversReturns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
functiononSocketConnect virtualCalled 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.
functiononSocketRecv virtualCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtualCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtualCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
variable_sender
variable_receivers
variable_dirty
functioncleanupReceivers virtual

Public Methods

ReturnNameDescription
ConnectionAdapterCreates a ConnectionAdapter for the given connection.
ssize_tsend virtual overrideSends data to the peer, flushing the outgoing HTTP header first if needed.
ssize_tsendOwned virtual overrideSends an owned payload buffer to the connected peer.
voidremoveReceiver overrideRemove the given receiver.
Parser &parser nodiscardReturns the HTTP parser instance.
Connection *connection nodiscardReturns the owning Connection pointer, or nullptr if detached.
voidresetResets 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-2}

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

  • connection Owning HTTP connection.

  • type Parser type: HTTP_REQUEST for server side, HTTP_RESPONSE for client side.


{#send-12}

send

virtual override

virtual ssize_t send(const char * data, size_t len, int flags = 0) override

Defined in src/http/include/icy/http/connection.h:175

Sends data to the peer, flushing the outgoing HTTP header first if needed.

Parameters

  • data Pointer to the data buffer.

  • len Number of bytes to send.

  • flags Send flags (unused for HTTP, used for WebSocket frame type).

Returns

Number of bytes sent, or -1 on error.

Reimplements

{#sendowned-11}

sendOwned

virtual override

virtual ssize_t sendOwned(Buffer && buffer, int flags = 0) override

Defined 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-2}

removeReceiver

override

void removeReceiver(SocketAdapter * adapter) override

Defined 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

nodiscard

[[nodiscard]] Parser & parser()

Defined in src/http/include/icy/http/connection.h:185

Returns the HTTP parser instance.


{#connection-3}

connection

nodiscard

[[nodiscard]] Connection * connection()

Defined in src/http/include/icy/http/connection.h:188

Returns the owning Connection pointer, or nullptr if detached.


{#reset-7}

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

  • sender New socket adapter to send data through.

  • request New HTTP request object for the parser to populate.

Protected Attributes

ReturnNameDescription
Connection *_connection
Parser_parser

{#_connection}

_connection

Connection * _connection

Defined in src/http/include/icy/http/connection.h:208


{#_parser}

_parser

Parser _parser

Defined in src/http/include/icy/http/connection.h:209

Protected Methods

ReturnNameDescription
boolonSocketRecv virtual overrideSocketAdapter interface.
voidonParserHeader virtual overrideHTTP Parser interface.
voidonParserHeadersEnd virtual overrideCalled when all HTTP headers have been parsed.
voidonParserChunk virtual overrideCalled for each chunk of body data received.
voidonParserError virtual overrideCalled when a parse error occurs.
voidonParserEnd virtual overrideCalled when the HTTP message is fully parsed.

{#onsocketrecv-4}

onSocketRecv

virtual override

virtual bool onSocketRecv(net::Socket & socket, const MutableBuffer & buffer, const net::Address & peerAddress) override

Defined in src/http/include/icy/http/connection.h:199

SocketAdapter interface.

Reimplements

{#onparserheader}

onParserHeader

virtual override

virtual void onParserHeader(const std::string & name, const std::string & value) override

Defined in src/http/include/icy/http/connection.h:202

HTTP Parser interface.

Reimplements

{#onparserheadersend}

onParserHeadersEnd

virtual override

virtual void onParserHeadersEnd(bool upgrade) override

Defined in src/http/include/icy/http/connection.h:203

Called when all HTTP headers have been parsed.

Parameters

  • upgrade True if the connection should be upgraded (e.g. to WebSocket).
Reimplements

{#onparserchunk}

onParserChunk

virtual override

virtual void onParserChunk(const char * data, size_t len) override

Defined in src/http/include/icy/http/connection.h:204

Called for each chunk of body data received.

Parameters

  • data Pointer to the body data chunk.

  • len Length of the chunk in bytes.

Reimplements

{#onparsererror}

onParserError

virtual override

virtual void onParserError(const icy::Error & err) override

Defined in src/http/include/icy/http/connection.h:205

Called when a parse error occurs.

Parameters

  • err Error details from llhttp.
Reimplements

{#onparserend}

onParserEnd

virtual override

virtual void onParserEnd() override

Defined in src/http/include/icy/http/connection.h:206

Called when the HTTP message is fully parsed.

Reimplements

{#connectionpool}

ConnectionPool

#include <icy/http/server.h>
class ConnectionPool

Defined in src/http/include/icy/http/server.h:291

LIFO connection pool for reusing ServerConnection objects. Avoids per-request heap allocation by resetting and reusing connections instead of destroying and recreating them.

List of all members

NameKindOwner
acquirefunctionDeclared here
releasefunctionDeclared here
setMaxSizefunctionDeclared here
sizefunctionDeclared here
_poolvariableDeclared here
_maxSizevariableDeclared here

Public Methods

ReturnNameDescription
ServerConnection::Ptracquire inlineTakes a connection from the pool for reuse.
boolrelease inlineReturns a connection to the pool after use.
voidsetMaxSize inlineSets the maximum number of connections the pool will hold.
size_tsize const inline nodiscardReturns the current number of connections held in the pool.

{#acquire}

acquire

inline

inline ServerConnection::Ptr acquire()

Defined in src/http/include/icy/http/server.h:296

Takes a connection from the pool for reuse.

Returns

A pooled connection, or nullptr if the pool is empty.


{#release}

release

inline

inline bool release(ServerConnection::Ptr & conn)

Defined in src/http/include/icy/http/server.h:307

Returns a connection to the pool after use.

Parameters

  • conn The connection to return.

Returns

true if accepted into the pool; false if the pool is full.


{#setmaxsize}

setMaxSize

inline

inline void setMaxSize(size_t n)

Defined in src/http/include/icy/http/server.h:316

Sets the maximum number of connections the pool will hold.

Parameters

  • n Maximum pool capacity.

{#size}

size

const inline nodiscard

[[nodiscard]] inline size_t size() const

Defined in src/http/include/icy/http/server.h:319

Returns the current number of connections held in the pool.

Private Attributes

ReturnNameDescription
std::vector< ServerConnection::Ptr >_pool
size_t_maxSize

{#_pool}

_pool

std::vector< ServerConnection::Ptr > _pool

Defined in src/http/include/icy/http/server.h:322


{#_maxsize}

_maxSize

size_t _maxSize = 128

Defined in src/http/include/icy/http/server.h:323

{#connectionstream-1}

ConnectionStream

#include <icy/http/connection.h>
class ConnectionStream

Defined in src/http/include/icy/http/connection.h:261

Inherits: SocketAdapter

Packet stream wrapper for an HTTP connection.

List of all members

NameKindOwner
OutgoingvariableDeclared here
IncomingvariableDeclared here
IncomingProgressvariableDeclared here
OutgoingProgressvariableDeclared here
ConnectionStreamfunctionDeclared here
sendfunctionDeclared here
connectionfunctionDeclared here
_connectionvariableDeclared here
onSocketRecvfunctionDeclared here
priorityvariableInherited from SocketAdapter
SocketAdapterfunctionInherited from SocketAdapter
~SocketAdapterfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
setSenderfunctionInherited from SocketAdapter
senderfunctionInherited from SocketAdapter
addReceiverfunctionInherited from SocketAdapter
removeReceiverfunctionInherited from SocketAdapter
hasReceiverfunctionInherited from SocketAdapter
receiversfunctionInherited from SocketAdapter
onSocketConnectfunctionInherited from SocketAdapter
onSocketRecvfunctionInherited from SocketAdapter
onSocketErrorfunctionInherited from SocketAdapter
onSocketClosefunctionInherited from SocketAdapter
_sendervariableInherited from SocketAdapter
_receiversvariableInherited from SocketAdapter
_dirtyvariableInherited from SocketAdapter
cleanupReceiversfunctionInherited from SocketAdapter

Inherited from SocketAdapter

KindNameDescription
variablepriorityThe priority of this adapter for STL sort operations.
functionSocketAdapterCreates the SocketAdapter.
function~SocketAdapter virtual noexceptDestroys the SocketAdapter.
functionsend virtual nodiscardSends 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.
functionsend virtual nodiscard
functionsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
functionsendOwned virtual nodiscard
functionsendPacket virtualSends 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.
functionsendPacket virtual
functionsendPacket virtualSends 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.
functionsetSender virtualSets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
functionsenderReturns the output SocketAdapter pointer.
functionaddReceiver virtualSets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
functionremoveReceiver virtualRemove the given receiver.
functionhasReceiver virtualReturns true if the given receiver is connected.
functionreceiversReturns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
functiononSocketConnect virtualCalled 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.
functiononSocketRecv virtualCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtualCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtualCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
variable_sender
variable_receivers
variable_dirty
functioncleanupReceivers virtual

Public Attributes

ReturnNameDescription
PacketStreamOutgoingThe Outgoing stream is responsible for packetizing raw application data into the agreed upon HTTP format and sending it to the peer.
PacketStreamIncomingThe Incoming stream emits incoming HTTP packets for processing by the application.
ProgressSignalIncomingProgressFired on download progress.
ProgressSignalOutgoingProgressFired on upload progress.

{#outgoing}

Outgoing

PacketStream Outgoing

Defined in src/http/include/icy/http/connection.h:280

The Outgoing stream is responsible for packetizing raw application data into the agreed upon HTTP format and sending it to the peer.


{#incoming}

Incoming

PacketStream Incoming

Defined in src/http/include/icy/http/connection.h:286

The Incoming stream emits incoming HTTP packets for processing by the application.

This is useful for example when writing incoming data to a file.


{#incomingprogress-1}

IncomingProgress

ProgressSignal IncomingProgress

Defined in src/http/include/icy/http/connection.h:288

Fired on download progress.


{#outgoingprogress}

OutgoingProgress

ProgressSignal OutgoingProgress

Defined in src/http/include/icy/http/connection.h:289

Fired on upload progress.

Public Methods

ReturnNameDescription
ConnectionStreamCreates a ConnectionStream wrapping the given HTTP connection. Wires the Outgoing stream emitter to the connection adapter and registers this stream to receive incoming data from the adapter.
ssize_tsend virtual overrideSend data via the Outgoing stream.
Connection::Ptrconnection nodiscardReturn a reference to the underlying connection.

{#connectionstream-2}

ConnectionStream

ConnectionStream(Connection::Ptr connection)

Defined in src/http/include/icy/http/connection.h:268

Creates a ConnectionStream wrapping the given HTTP connection. Wires the Outgoing stream emitter to the connection adapter and registers this stream to receive incoming data from the adapter.

Parameters

  • connection The HTTP connection to wrap.

{#send-13}

send

virtual override

virtual ssize_t send(const char * data, size_t len, int flags = 0) override

Defined in src/http/include/icy/http/connection.h:272

Send data via the Outgoing stream.

Reimplements

{#connection-4}

connection

nodiscard

[[nodiscard]] Connection::Ptr connection()

Defined in src/http/include/icy/http/connection.h:275

Return a reference to the underlying connection.

Protected Attributes

ReturnNameDescription
Connection::Ptr_connection

{#_connection-1}

_connection

Connection::Ptr _connection

Defined in src/http/include/icy/http/connection.h:294

Protected Methods

ReturnNameDescription
boolonSocketRecv virtual overrideCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.

{#onsocketrecv-5}

onSocketRecv

virtual override

virtual bool onSocketRecv(net::Socket & socket, const MutableBuffer & buffer, const net::Address & peerAddress) override

Defined in src/http/include/icy/http/connection.h:292

Called when data is received from the socket. Forwards the event to all registered receivers in priority order.

Parameters

  • socket The socket that received data.

  • buffer The received data buffer.

  • peerAddress Address of the sender.

Returns

true to stop propagation to subsequent receivers.

Reimplements

{#cookie}

#include <icy/http/cookie.h>
class Cookie

Defined in src/http/include/icy/http/cookie.h:39

HTTP cookie value plus its response/header attributes.

A cookie is a small amount of information sent by a Web server to a Web browser, saved by the browser, and later sent back to the server. A cookie's value can uniquely identify a client, so cookies are commonly used for session management.

A cookie has a name, a single value, and optional attributes such as a comment, path and domain qualifiers, a maximum age, and a version number.

This class supports both the Version 0 (by Netscape) and Version 1 (by RFC 2109) cookie specifications. By default, cookies are created using Version 0 to ensure the best interoperability.

List of all members

NameKindOwner
CookiefunctionDeclared here
CookiefunctionDeclared here
CookiefunctionDeclared here
CookiefunctionDeclared here
CookiefunctionDeclared here
~CookiefunctionDeclared here
operator=functionDeclared here
setVersionfunctionDeclared here
getVersionfunctionDeclared here
setNamefunctionDeclared here
getNamefunctionDeclared here
setValuefunctionDeclared here
getValuefunctionDeclared here
setCommentfunctionDeclared here
getCommentfunctionDeclared here
setDomainfunctionDeclared here
getDomainfunctionDeclared here
setPathfunctionDeclared here
getPathfunctionDeclared here
setSecurefunctionDeclared here
getSecurefunctionDeclared here
setMaxAgefunctionDeclared here
getMaxAgefunctionDeclared here
setHttpOnlyfunctionDeclared here
getHttpOnlyfunctionDeclared here
toStringfunctionDeclared here
escapefunctionDeclared here
unescapefunctionDeclared here
_versionvariableDeclared here
_namevariableDeclared here
_valuevariableDeclared here
_commentvariableDeclared here
_domainvariableDeclared here
_pathvariableDeclared here
_securevariableDeclared here
_maxAgevariableDeclared here
_httpOnlyvariableDeclared here

Public Methods

ReturnNameDescription
CookieCreates an empty Cookie.
Cookie explicitCreates a cookie with the given name. The cookie never expires.
Cookie explicitCreates a cookie from the given NVCollection.
CookieCreates a cookie with the given name and value. The cookie never expires.
CookieCreates the Cookie by copying another one.
~CookieDestroys the Cookie.
Cookie &operator=Assigns a cookie.
voidsetVersionSets the version of the cookie.
intgetVersion const inline nodiscardReturns the version of the cookie, which is either 0 or 1.
voidsetNameSets the name of the cookie.
const std::string &getName const inline nodiscardReturns the name of the cookie.
voidsetValueSets the value of the cookie.
const std::string &getValue const inline nodiscardReturns the value of the cookie.
voidsetCommentSets the comment for the cookie.
const std::string &getComment const inline nodiscardReturns the comment for the cookie.
voidsetDomainSets the domain for the cookie.
const std::string &getDomain const inline nodiscardReturns the domain for the cookie.
voidsetPathSets the path for the cookie.
const std::string &getPath const inline nodiscardReturns the path for the cookie.
voidsetSecureSets the value of the secure flag for the cookie.
boolgetSecure const inline nodiscardReturns the value of the secure flag for the cookie.
voidsetMaxAgeSets the maximum age in seconds for the cookie.
intgetMaxAge const inline nodiscardReturns the maximum age in seconds for the cookie.
voidsetHttpOnlySets the HttpOnly flag for the cookie.
boolgetHttpOnly const inline nodiscardReturns true if the cookie's HttpOnly flag is set.
std::stringtoString const nodiscardReturns a std::string representation of the cookie, suitable for use in a Set-Cookie header.

{#cookie-1}

Cookie()

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

Creates an empty Cookie.


{#cookie-2}

explicit

explicit Cookie(const std::string & name)

Defined in src/http/include/icy/http/cookie.h:47

Creates a cookie with the given name. The cookie never expires.


{#cookie-3}

explicit

explicit Cookie(const NVCollection & nvc)

Defined in src/http/include/icy/http/cookie.h:50

Creates a cookie from the given NVCollection.


{#cookie-4}

Cookie(const std::string & name, const std::string & value)

Defined in src/http/include/icy/http/cookie.h:58

Creates a cookie with the given name and value. The cookie never expires.

Note: If value contains whitespace or non-alphanumeric characters, the value should be escaped by calling escape() before passing it to the constructor.


{#cookie-5}

Cookie(const Cookie & cookie)

Defined in src/http/include/icy/http/cookie.h:61

Creates the Cookie by copying another one.


{#cookie-6}

~Cookie()

Defined in src/http/include/icy/http/cookie.h:64

Destroys the Cookie.


{#operator-16}

operator=

Cookie & operator=(const Cookie & cookie)

Defined in src/http/include/icy/http/cookie.h:67

Assigns a cookie.


{#setversion}

setVersion

void setVersion(int version)

Defined in src/http/include/icy/http/cookie.h:73

Sets the version of the cookie.

Version must be either 0 (denoting a Netscape cookie) or 1 (denoting a RFC 2109 cookie).


{#getversion}

getVersion

const inline nodiscard

[[nodiscard]] inline int getVersion() const

Defined in src/http/include/icy/http/cookie.h:77

Returns the version of the cookie, which is either 0 or 1.


{#setname}

setName

void setName(const std::string & name)

Defined in src/http/include/icy/http/cookie.h:80

Sets the name of the cookie.


{#getname}

getName

const inline nodiscard

[[nodiscard]] inline const std::string & getName() const

Defined in src/http/include/icy/http/cookie.h:83

Returns the name of the cookie.


{#setvalue}

setValue

void setValue(const std::string & value)

Defined in src/http/include/icy/http/cookie.h:93

Sets the value of the cookie.

According to the cookie specification, the size of the value should not exceed 4 Kbytes.

Note: If value contains whitespace or non-alphanumeric characters, the value should be escaped by calling escape() prior to passing it to setName().


{#getvalue}

getValue

const inline nodiscard

[[nodiscard]] inline const std::string & getValue() const

Defined in src/http/include/icy/http/cookie.h:96

Returns the value of the cookie.


{#setcomment}

setComment

void setComment(const std::string & comment)

Defined in src/http/include/icy/http/cookie.h:101

Sets the comment for the cookie.

Comments are only supported for version 1 cookies.


{#getcomment}

getComment

const inline nodiscard

[[nodiscard]] inline const std::string & getComment() const

Defined in src/http/include/icy/http/cookie.h:104

Returns the comment for the cookie.


{#setdomain}

setDomain

void setDomain(const std::string & domain)

Defined in src/http/include/icy/http/cookie.h:107

Sets the domain for the cookie.


{#getdomain}

getDomain

const inline nodiscard

[[nodiscard]] inline const std::string & getDomain() const

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

Returns the domain for the cookie.


{#setpath}

setPath

void setPath(const std::string & path)

Defined in src/http/include/icy/http/cookie.h:113

Sets the path for the cookie.


{#getpath}

getPath

const inline nodiscard

[[nodiscard]] inline const std::string & getPath() const

Defined in src/http/include/icy/http/cookie.h:116

Returns the path for the cookie.


{#setsecure}

setSecure

void setSecure(bool secure)

Defined in src/http/include/icy/http/cookie.h:120

Sets the value of the secure flag for the cookie.


{#getsecure}

getSecure

const inline nodiscard

[[nodiscard]] inline bool getSecure() const

Defined in src/http/include/icy/http/cookie.h:124

Returns the value of the secure flag for the cookie.


{#setmaxage}

setMaxAge

void setMaxAge(int maxAge)

Defined in src/http/include/icy/http/cookie.h:134

Sets the maximum age in seconds for the cookie.

A value of -1 causes the cookie to never expire on the client.

A value of 0 deletes the cookie on the client.


{#getmaxage}

getMaxAge

const inline nodiscard

[[nodiscard]] inline int getMaxAge() const

Defined in src/http/include/icy/http/cookie.h:138

Returns the maximum age in seconds for the cookie.


{#sethttponly}

setHttpOnly

void setHttpOnly(bool flag = true)

Defined in src/http/include/icy/http/cookie.h:141

Sets the HttpOnly flag for the cookie.


{#gethttponly}

getHttpOnly

const inline nodiscard

[[nodiscard]] inline bool getHttpOnly() const

Defined in src/http/include/icy/http/cookie.h:144

Returns true if the cookie's HttpOnly flag is set.


{#tostring-5}

toString

const nodiscard

[[nodiscard]] std::string toString() const

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

Returns a std::string representation of the cookie, suitable for use in a Set-Cookie header.

Public Static Methods

ReturnNameDescription
std::stringescape staticEscapes the given std::string by replacing all non-alphanumeric characters with escape sequences in the form xx, where xx is the hexadecimal character code.
std::stringunescape staticUnescapes the given std::string by replacing all escape sequences in the form xx with the respective characters.

{#escape}

escape

static

static std::string escape(std::string_view str)

Defined in src/http/include/icy/http/cookie.h:154

Escapes the given std::string by replacing all non-alphanumeric characters with escape sequences in the form xx, where xx is the hexadecimal character code.


{#unescape}

unescape

static

static std::string unescape(std::string_view str)

Defined in src/http/include/icy/http/cookie.h:159

Unescapes the given std::string by replacing all escape sequences in the form xx with the respective characters.

Private Attributes

ReturnNameDescription
int_version
std::string_name
std::string_value
std::string_comment
std::string_domain
std::string_path
bool_secure
int_maxAge
bool_httpOnly

{#_version}

_version

int _version

Defined in src/http/include/icy/http/cookie.h:162


{#_name}

_name

std::string _name

Defined in src/http/include/icy/http/cookie.h:163


{#_value}

_value

std::string _value

Defined in src/http/include/icy/http/cookie.h:164


{#_comment}

_comment

std::string _comment

Defined in src/http/include/icy/http/cookie.h:165


{#_domain}

_domain

std::string _domain

Defined in src/http/include/icy/http/cookie.h:166


{#_path}

_path

std::string _path

Defined in src/http/include/icy/http/cookie.h:167


{#_secure}

_secure

bool _secure

Defined in src/http/include/icy/http/cookie.h:168


{#_maxage}

_maxAge

int _maxAge

Defined in src/http/include/icy/http/cookie.h:169


{#_httponly}

_httpOnly

bool _httpOnly

Defined in src/http/include/icy/http/cookie.h:170

{#filepart}

FilePart

#include <icy/http/form.h>
class FilePart

Defined in src/http/include/icy/http/form.h:236

Inherits: FormPart

Form part backed by a file on disk.

List of all members

NameKindOwner
FilePartfunctionDeclared here
FilePartfunctionDeclared here
FilePartfunctionDeclared here
~FilePartfunctionDeclared here
openfunctionDeclared here
resetfunctionDeclared here
writeChunkfunctionDeclared here
writefunctionDeclared here
writefunctionDeclared here
filenamefunctionDeclared here
streamfunctionDeclared here
lengthfunctionDeclared here
_pathvariableDeclared here
_filenamevariableDeclared here
_istrvariableDeclared here
_fileSizevariableDeclared here
FormPartfunctionInherited from FormPart
~FormPartfunctionInherited from FormPart
resetfunctionInherited from FormPart
writeChunkfunctionInherited from FormPart
writefunctionInherited from FormPart
writefunctionInherited from FormPart
headersfunctionInherited from FormPart
initialWritefunctionInherited from FormPart
contentTypefunctionInherited from FormPart
lengthfunctionInherited from FormPart
_contentTypevariableInherited from FormPart
_lengthvariableInherited from FormPart
_headersvariableInherited from FormPart
_initialWritevariableInherited from FormPart

Inherited from FormPart

KindNameDescription
functionFormPartCreates the FormPart with the given MIME content type.
function~FormPart virtualDestroys the FormPart.
functionreset virtualResets the internal state and write position to the beginning. Called by FormWriter when retrying or recalculating content length.
functionwriteChunk virtualWrites the next chunk of data to the FormWriter.
functionwrite virtualWrites the entire part data to the FormWriter in one call.
functionwrite virtualWrites the entire part data to an output stream (used for content-length calculation).
functionheaders nodiscardReturns the extra MIME headers for this part (e.g. Content-Disposition).
functioninitialWrite virtual const nodiscardReturns true if this is the first write call since construction or reset().
functioncontentType const nodiscardReturns the MIME content type for this part.
functionlength virtual const nodiscardReturns the total byte length of the part data.
variable_contentType
variable_length
variable_headers
variable_initialWrite

Public Methods

ReturnNameDescription
FilePartCreates the FilePart for the given path.
FilePartCreates the FilePart for the given path and MIME type.
FilePartCreates the FilePart for the given path and MIME type. The given filename is used as part filename (see filename()) only.
~FilePart virtualDestroys the FilePart.
voidopen virtualOpens the file for reading.
voidreset virtual overrideResets the file stream to the beginning and clears initial-write state.
boolwriteChunk virtual overrideWrites the next chunk of the file to the FormWriter.
voidwrite virtual overrideWrites the entire file content to the FormWriter.
voidwrite virtual overrideWrites the entire file content to an output stream (used for content-length calculation).
const std::string &filename const nodiscardReturns the filename component of the file path (not the full path).
std::ifstream &stream nodiscardReturns a reference to the underlying file input stream.
uint64_tlength virtual const nodiscard overrideReturns the total file size in bytes.

{#filepart-1}

FilePart

FilePart(const std::string & path)

Defined in src/http/include/icy/http/form.h:244

Creates the FilePart for the given path.

The MIME type is set to application/octet-stream.

Throws an FileException if the file cannot be opened.


{#filepart-2}

FilePart

FilePart(const std::string & path, const std::string & contentType)

Defined in src/http/include/icy/http/form.h:250

Creates the FilePart for the given path and MIME type.

Throws an FileException if the file cannot be opened.


{#filepart-3}

FilePart

FilePart(const std::string & path, const std::string & filename, const std::string & contentType)

Defined in src/http/include/icy/http/form.h:257

Creates the FilePart for the given path and MIME type. The given filename is used as part filename (see filename()) only.

Throws an FileException if the file cannot be opened.


{#filepart-4}

~FilePart

virtual

virtual ~FilePart()

Defined in src/http/include/icy/http/form.h:261

Destroys the FilePart.


{#open-4}

open

virtual

virtual void open()

Defined in src/http/include/icy/http/form.h:265

Opens the file for reading.

Exceptions

  • std::runtime_error if the file cannot be opened.

{#reset-8}

reset

virtual override

virtual void reset() override

Defined in src/http/include/icy/http/form.h:268

Resets the file stream to the beginning and clears initial-write state.

Reimplements

{#writechunk}

writeChunk

virtual override

virtual bool writeChunk(FormWriter & writer) override

Defined in src/http/include/icy/http/form.h:273

Writes the next chunk of the file to the FormWriter.

Parameters

  • writer The FormWriter to send the chunk through.

Returns

true if more data remains; false when the file is fully sent.

Reimplements

{#write-2}

write

virtual override

virtual void write(FormWriter & writer) override

Defined in src/http/include/icy/http/form.h:277

Writes the entire file content to the FormWriter.

Parameters

Reimplements

{#write-3}

write

virtual override

virtual void write(std::ostream & ostr) override

Defined in src/http/include/icy/http/form.h:281

Writes the entire file content to an output stream (used for content-length calculation).

Parameters

  • ostr Output stream to write to.
Reimplements

{#filename-1}

filename

const nodiscard

[[nodiscard]] const std::string & filename() const

Defined in src/http/include/icy/http/form.h:284

Returns the filename component of the file path (not the full path).


{#stream-3}

stream

nodiscard

[[nodiscard]] std::ifstream & stream()

Defined in src/http/include/icy/http/form.h:287

Returns a reference to the underlying file input stream.


{#length-1}

length

virtual const nodiscard override

[[nodiscard]] virtual uint64_t length() const override

Defined in src/http/include/icy/http/form.h:290

Returns the total file size in bytes.

Reimplements

Protected Attributes

ReturnNameDescription
std::string_path
std::string_filename
std::ifstream_istr
uint64_t_fileSize

{#_path-1}

_path

std::string _path

Defined in src/http/include/icy/http/form.h:293


{#_filename-1}

_filename

std::string _filename

Defined in src/http/include/icy/http/form.h:294


{#_istr}

_istr

std::ifstream _istr

Defined in src/http/include/icy/http/form.h:295


{#_filesize}

_fileSize

uint64_t _fileSize

Defined in src/http/include/icy/http/form.h:296

{#formpart}

FormPart

#include <icy/http/form.h>
class FormPart

Defined in src/http/include/icy/http/form.h:183

Subclassed by: FilePart, StringPart

An implementation of FormPart.

List of all members

NameKindOwner
FormPartfunctionDeclared here
~FormPartfunctionDeclared here
resetfunctionDeclared here
writeChunkfunctionDeclared here
writefunctionDeclared here
writefunctionDeclared here
headersfunctionDeclared here
initialWritefunctionDeclared here
contentTypefunctionDeclared here
lengthfunctionDeclared here
_contentTypevariableDeclared here
_lengthvariableDeclared here
_headersvariableDeclared here
_initialWritevariableDeclared here

Public Methods

ReturnNameDescription
FormPartCreates the FormPart with the given MIME content type.
~FormPart virtualDestroys the FormPart.
voidreset virtualResets the internal state and write position to the beginning. Called by FormWriter when retrying or recalculating content length.
boolwriteChunk virtualWrites the next chunk of data to the FormWriter.
voidwrite virtualWrites the entire part data to the FormWriter in one call.
voidwrite virtualWrites the entire part data to an output stream (used for content-length calculation).
NVCollection &headers nodiscardReturns the extra MIME headers for this part (e.g. Content-Disposition).
boolinitialWrite virtual const nodiscardReturns true if this is the first write call since construction or reset().
const std::string &contentType const nodiscardReturns the MIME content type for this part.
uint64_tlength virtual const nodiscardReturns the total byte length of the part data.

{#formpart-1}

FormPart

FormPart(const std::string & contentType = "application/octet-stream")

Defined in src/http/include/icy/http/form.h:188

Creates the FormPart with the given MIME content type.

Parameters

  • contentType MIME type for this part (default: "application/octet-stream").

{#formpart-2}

~FormPart

virtual

virtual ~FormPart()

Defined in src/http/include/icy/http/form.h:191

Destroys the FormPart.


{#reset-9}

reset

virtual

virtual void reset()

Defined in src/http/include/icy/http/form.h:195

Resets the internal state and write position to the beginning. Called by FormWriter when retrying or recalculating content length.

Reimplemented by

{#writechunk-1}

writeChunk

virtual

virtual bool writeChunk(FormWriter & writer)

Defined in src/http/include/icy/http/form.h:200

Writes the next chunk of data to the FormWriter.

Parameters

  • writer The FormWriter to send the chunk through.

Returns

true if more data remains to be written; false when complete.

Reimplemented by

{#write-4}

write

virtual

virtual void write(FormWriter & writer)

Defined in src/http/include/icy/http/form.h:204

Writes the entire part data to the FormWriter in one call.

Parameters

Reimplemented by

{#write-5}

write

virtual

virtual void write(std::ostream & ostr)

Defined in src/http/include/icy/http/form.h:208

Writes the entire part data to an output stream (used for content-length calculation).

Parameters

  • ostr Output stream to write to.
Reimplemented by

{#headers-1}

headers

nodiscard

[[nodiscard]] NVCollection & headers()

Defined in src/http/include/icy/http/form.h:211

Returns the extra MIME headers for this part (e.g. Content-Disposition).


{#initialwrite}

initialWrite

virtual const nodiscard

[[nodiscard]] virtual bool initialWrite() const

Defined in src/http/include/icy/http/form.h:214

Returns true if this is the first write call since construction or reset().


{#contenttype-1}

contentType

const nodiscard

[[nodiscard]] const std::string & contentType() const

Defined in src/http/include/icy/http/form.h:217

Returns the MIME content type for this part.


{#length-2}

length

virtual const nodiscard

[[nodiscard]] virtual uint64_t length() const

Defined in src/http/include/icy/http/form.h:220

Returns the total byte length of the part data.

Reimplemented by

Protected Attributes

ReturnNameDescription
std::string_contentType
uint64_t_length
NVCollection_headers
bool_initialWrite

{#_contenttype}

_contentType

std::string _contentType

Defined in src/http/include/icy/http/form.h:223


{#_length}

_length

uint64_t _length

Defined in src/http/include/icy/http/form.h:224


{#_headers}

_headers

NVCollection _headers

Defined in src/http/include/icy/http/form.h:225


{#_initialwrite}

_initialWrite

bool _initialWrite

Defined in src/http/include/icy/http/form.h:226

{#formwriter}

FormWriter

#include <icy/http/form.h>
class FormWriter

Defined in src/http/include/icy/http/form.h:42

Inherits: NVCollection, PacketStreamAdapter, Startable

FormWriter is an HTTP client connection adapter for writing HTML forms.

This class runs in its own thread so as not to block the event loop while uploading big files. Class members are not synchronized hence they should not be accessed while the form is sending, not that there would be any reason to do so.

List of all members

NameKindOwner
FormPartfriendDeclared here
FilePartfriendDeclared here
StringPartfriendDeclared here
emittervariableDeclared here
~FormWriterfunctionDeclared here
addPartfunctionDeclared here
startfunctionDeclared here
stopfunctionDeclared here
completefunctionDeclared here
cancelledfunctionDeclared here
prepareSubmitfunctionDeclared here
calculateMultipartContentLengthfunctionDeclared here
writeUrlfunctionDeclared here
writeMultipartChunkfunctionDeclared here
writeAsyncfunctionDeclared here
setEncodingfunctionDeclared here
encodingfunctionDeclared here
setBoundaryfunctionDeclared here
boundaryfunctionDeclared here
connectionfunctionDeclared here
ENCODING_URLvariableDeclared here
ENCODING_MULTIPART_FORMvariableDeclared here
ENCODING_MULTIPART_RELATEDvariableDeclared here
createfunctionDeclared here
_streamvariableDeclared here
_runnervariableDeclared here
_encodingvariableDeclared here
_boundaryvariableDeclared here
_partsvariableDeclared here
_filesLengthvariableDeclared here
_writeStatevariableDeclared here
_initialvariableDeclared here
_completevariableDeclared here
FormWriterfunctionDeclared here
FormWriterfunctionDeclared here
FormWriterfunctionDeclared here
writePartHeaderfunctionDeclared here
writeEndfunctionDeclared here
updateProgressfunctionDeclared here
MaptypedefInherited from NVCollection
IteratortypedefInherited from NVCollection
ConstIteratortypedefInherited from NVCollection
_mapvariableInherited from NVCollection
NVCollectionfunctionInherited from NVCollection
NVCollectionfunctionInherited from NVCollection
NVCollectionfunctionInherited from NVCollection
~NVCollectionfunctionInherited from NVCollection
operator=functionInherited from NVCollection
operator=functionInherited from NVCollection
operator[]functionInherited from NVCollection
setfunctionInherited from NVCollection
addfunctionInherited from NVCollection
addfunctionInherited from NVCollection
getfunctionInherited from NVCollection
getfunctionInherited from NVCollection
hasfunctionInherited from NVCollection
findfunctionInherited from NVCollection
beginfunctionInherited from NVCollection
endfunctionInherited from NVCollection
emptyfunctionInherited from NVCollection
sizefunctionInherited from NVCollection
erasefunctionInherited from NVCollection
clearfunctionInherited from NVCollection
_emittervariableInherited from PacketStreamAdapter
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
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
operator=functionInherited from PacketStreamAdapter
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
operator=functionInherited from PacketStreamAdapter
startfunctionInherited from Startable
stopfunctionInherited from Startable

Inherited from NVCollection

KindNameDescription
typedefMap
typedefIterator
typedefConstIterator
variable_map
functionNVCollection inline
functionNVCollection inline
functionNVCollection inline noexcept
function~NVCollection virtual inline
functionoperator=Assigns the name-value pairs of another NVCollection to this one.
functionoperator= noexcept
functionoperator[] constReturns the value of the (first) name-value pair with the given name.
functionsetSets the value of the (first) name-value pair with the given name.
functionaddAdds a new name-value pair with the given name and value.
functionaddAdds a new name-value pair using move semantics.
functionget constReturns the value of the first name-value pair with the given name.
functionget constReturns the value of the first name-value pair with the given name. If no value with the given name has been found, the defaultValue is returned.
functionhas constReturns true if there is at least one name-value pair with the given name.
functionfind constReturns an iterator pointing to the first name-value pair with the given name.
functionbegin constReturns an iterator pointing to the begin of the name-value pair collection.
functionend constReturns an iterator pointing to the end of the name-value pair collection.
functionempty constReturns true iff the header does not have any content.
functionsize constReturns the number of name-value pairs in the collection.
functioneraseRemoves all name-value pairs with the given name.
functionclearRemoves all name-value pairs and their values.

Inherited from PacketStreamAdapter

KindNameDescription
variable_emitter
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 const nodiscardReturns 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.
functionPacketStreamAdapterNonCopyable and NonMovable.
functionoperator=Deleted assignment operator.
functionPacketStreamAdapterDeleted constructor.
functionoperator=Deleted assignment operator.

Inherited from Startable

KindNameDescription
functionstart virtualStarts the object (e.g. begins processing or listening).
functionstop virtualStops the object (e.g. halts processing or closes resources).

Friends

NameDescription
FormPart
FilePart
StringPart

{#formpart-3}

FormPart

friend class FormPart

Defined in src/http/include/icy/http/form.h:152


{#filepart-5}

FilePart

friend class FilePart

Defined in src/http/include/icy/http/form.h:153


{#stringpart}

StringPart

friend class StringPart

Defined in src/http/include/icy/http/form.h:154

Public Attributes

ReturnNameDescription
PacketSignalemitterThe outgoing packet emitter.

{#emitter-6}

emitter

PacketSignal emitter

Defined in src/http/include/icy/http/form.h:122

The outgoing packet emitter.

Public Methods

ReturnNameDescription
~FormWriter virtualDestroys the FormWriter.
voidaddPartAdds a part or file attachment to the multipart form.
voidstart virtualStarts the sending thread.
voidstop virtualStops the sending thread.
boolcomplete const nodiscardReturns true if the request is complete.
boolcancelled const nodiscardReturns true if the request is cancelled.
voidprepareSubmitPrepares the outgoing HTTP request object for submitting the form.
uint64_tcalculateMultipartContentLengthProcesses the entire form body and computes its total byte length. Only meaningful for multipart/form-data when not using chunked encoding.
voidwriteUrlWrites the complete "application/x-www-form-urlencoded" encoded body to ostr. All key-value pairs from the NVCollection base are percent-encoded and joined with '&'.
voidwriteMultipartChunkWrites the next pending multipart chunk to the connection. Non-blocking; intended to be called repeatedly from the event loop until all parts have been sent.
voidwriteAsyncWrites the next message chunk from the background runner thread. Called by the Runner; do not call directly.
voidsetEncodingSets the MIME encoding used for submitting the form. Must be set before prepareSubmit() is called.
const std::string &encoding const nodiscardReturns the encoding used for posting the form.
voidsetBoundarySets the MIME boundary string used to delimit multipart form parts. If not set, a random boundary is generated by prepareSubmit(). Must be set before prepareSubmit() is called.
const std::string &boundary const nodiscardReturns the MIME boundary used for writing multipart form data.
ConnectionStream &connection nodiscardThe associated HTTP client connection.

{#formwriter-1}

~FormWriter

virtual

virtual ~FormWriter()

Defined in src/http/include/icy/http/form.h:57

Destroys the FormWriter.


{#addpart}

addPart

void addPart(const std::string & name, FormPart * part)

Defined in src/http/include/icy/http/form.h:65

Adds a part or file attachment to the multipart form.

The FormWriter takes ownership of part and deletes it when done. Parts are only sent when the encoding is "multipart/form-data".

Parameters

  • name Form field name for this part.

  • part Part to add. Ownership is transferred.


{#start-10}

start

virtual

virtual void start()

Defined in src/http/include/icy/http/form.h:68

Starts the sending thread.

Reimplements

{#stop-8}

stop

virtual

virtual void stop()

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

Stops the sending thread.

Reimplements

{#complete-1}

complete

const nodiscard

[[nodiscard]] bool complete() const

Defined in src/http/include/icy/http/form.h:74

Returns true if the request is complete.


{#cancelled-1}

cancelled

const nodiscard

[[nodiscard]] bool cancelled() const

Defined in src/http/include/icy/http/form.h:77

Returns true if the request is cancelled.


{#preparesubmit}

prepareSubmit

void prepareSubmit()

Defined in src/http/include/icy/http/form.h:80

Prepares the outgoing HTTP request object for submitting the form.


{#calculatemultipartcontentlength}

calculateMultipartContentLength

uint64_t calculateMultipartContentLength()

Defined in src/http/include/icy/http/form.h:85

Processes the entire form body and computes its total byte length. Only meaningful for multipart/form-data when not using chunked encoding.

Returns

Total content length in bytes.


{#writeurl}

writeUrl

void writeUrl(std::ostream & ostr)

Defined in src/http/include/icy/http/form.h:90

Writes the complete "application/x-www-form-urlencoded" encoded body to ostr. All key-value pairs from the NVCollection base are percent-encoded and joined with '&'.

Parameters

  • ostr Output stream to write to.

{#writemultipartchunk}

writeMultipartChunk

void writeMultipartChunk()

Defined in src/http/include/icy/http/form.h:95

Writes the next pending multipart chunk to the connection. Non-blocking; intended to be called repeatedly from the event loop until all parts have been sent.


{#writeasync}

writeAsync

void writeAsync()

Defined in src/http/include/icy/http/form.h:99

Writes the next message chunk from the background runner thread. Called by the Runner; do not call directly.


{#setencoding}

setEncoding

void setEncoding(const std::string & encoding)

Defined in src/http/include/icy/http/form.h:104

Sets the MIME encoding used for submitting the form. Must be set before prepareSubmit() is called.

Parameters

  • encoding MIME type: ENCODING_URL or ENCODING_MULTIPART_FORM.

{#encoding}

encoding

const nodiscard

[[nodiscard]] const std::string & encoding() const

Defined in src/http/include/icy/http/form.h:107

Returns the encoding used for posting the form.


{#setboundary}

setBoundary

void setBoundary(const std::string & boundary)

Defined in src/http/include/icy/http/form.h:113

Sets the MIME boundary string used to delimit multipart form parts. If not set, a random boundary is generated by prepareSubmit(). Must be set before prepareSubmit() is called.

Parameters

  • boundary Boundary string (without leading "--").

{#boundary}

boundary

const nodiscard

[[nodiscard]] const std::string & boundary() const

Defined in src/http/include/icy/http/form.h:116

Returns the MIME boundary used for writing multipart form data.


{#connection-5}

connection

nodiscard

[[nodiscard]] ConnectionStream & connection()

Defined in src/http/include/icy/http/form.h:119

The associated HTTP client connection.

Public Static Attributes

ReturnNameDescription
const char *ENCODING_URL static"application/x-www-form-urlencoded"
const char *ENCODING_MULTIPART_FORM static"multipart/form-data"
const char *ENCODING_MULTIPART_RELATED static"multipart/related" http://tools.ietf.org/html/rfc2387

{#encoding_url}

ENCODING_URL

static

const char * ENCODING_URL

Defined in src/http/include/icy/http/form.h:124

"application/x-www-form-urlencoded"


{#encoding_multipart_form}

ENCODING_MULTIPART_FORM

static

const char * ENCODING_MULTIPART_FORM

Defined in src/http/include/icy/http/form.h:125

"multipart/form-data"


{#encoding_multipart_related}

static

const char * ENCODING_MULTIPART_RELATED

Defined in src/http/include/icy/http/form.h:126

"multipart/related" http://tools.ietf.org/html/rfc2387

Public Static Methods

ReturnNameDescription
FormWriter *create staticCreates a FormWriter for the given connection and encoding.

{#create-7}

create

static

static FormWriter * create(ConnectionStream & conn, const std::string & encoding = FormWriter::ENCODING_URL)

Defined in src/http/include/icy/http/form.h:54

Creates a FormWriter for the given connection and encoding.

Encoding must be either "application/x-www-form-urlencoded" (which is the default) or "multipart/form-data".

Parameters

  • conn The HTTP connection stream to write form data to.

  • encoding MIME encoding type.

Returns

Heap-allocated FormWriter. The caller owns the returned pointer.

Protected Attributes

ReturnNameDescription
ConnectionStream &_stream
std::shared_ptr< Runner >_runner
std::string_encoding
std::string_boundary
PartQueue_parts
uint64_t_filesLength
int_writeState
bool_initial
bool_complete

{#_stream}

_stream

ConnectionStream & _stream

Defined in src/http/include/icy/http/form.h:165


{#_runner}

_runner

std::shared_ptr< Runner > _runner

Defined in src/http/include/icy/http/form.h:166


{#_encoding}

_encoding

std::string _encoding

Defined in src/http/include/icy/http/form.h:167


{#_boundary}

_boundary

std::string _boundary

Defined in src/http/include/icy/http/form.h:168


{#_parts}

_parts

PartQueue _parts

Defined in src/http/include/icy/http/form.h:169


{#_fileslength}

_filesLength

uint64_t _filesLength

Defined in src/http/include/icy/http/form.h:170


{#_writestate}

_writeState

int _writeState

Defined in src/http/include/icy/http/form.h:171


{#_initial}

_initial

bool _initial

Defined in src/http/include/icy/http/form.h:172


{#_complete-1}

_complete

bool _complete

Defined in src/http/include/icy/http/form.h:173

Protected Methods

ReturnNameDescription
FormWriterCreates the FormWriter that uses the given encoding.
FormWriterDeleted constructor.
FormWriterDeleted constructor.
voidwritePartHeaderWrites the message boundary std::string, followed by the message header to the output stream.
voidwriteEndWrites the final boundary std::string to the output stream.
voidupdateProgress virtualUpdates the upload progress via the associated ConnectionStream object.

{#formwriter-2}

FormWriter

FormWriter(ConnectionStream & conn, std::shared_ptr< Runner > runner, const std::string & encoding = FormWriter::ENCODING_URL)

Defined in src/http/include/icy/http/form.h:130

Creates the FormWriter that uses the given encoding.


{#formwriter-3}

FormWriter

FormWriter(const FormWriter &) = delete

Defined in src/http/include/icy/http/form.h:133

Deleted constructor.


{#formwriter-4}

FormWriter

FormWriter(FormWriter &&) = delete

Defined in src/http/include/icy/http/form.h:135

Deleted constructor.


{#writepartheader}

writePartHeader

void writePartHeader(const NVCollection & header, std::ostream & ostr)

Defined in src/http/include/icy/http/form.h:140

Writes the message boundary std::string, followed by the message header to the output stream.


{#writeend}

writeEnd

void writeEnd(std::ostream & ostr)

Defined in src/http/include/icy/http/form.h:143

Writes the final boundary std::string to the output stream.


{#updateprogress}

updateProgress

virtual

virtual void updateProgress(int nread)

Defined in src/http/include/icy/http/form.h:150

Updates the upload progress via the associated ConnectionStream object.

{#part}

Part

#include <icy/http/form.h>
struct Part

Defined in src/http/include/icy/http/form.h:157

Individual part within a multipart form submission.

List of all members

NameKindOwner
namevariableDeclared here
partvariableDeclared here

Public Attributes

ReturnNameDescription
std::stringname
std::unique_ptr< FormPart >part

{#name-5}

name

std::string name

Defined in src/http/include/icy/http/form.h:159


{#part-1}

part

std::unique_ptr< FormPart > part

Defined in src/http/include/icy/http/form.h:160

{#message}

Message

#include <icy/http/message.h>
class Message

Defined in src/http/include/icy/http/message.h:28

Inherits: NVCollection Subclassed by: Request, Response

The base class for Request and Response.

Defines the common properties of all HTTP messages. These are version, content length, content type and transfer encoding.

List of all members

NameKindOwner
setVersionfunctionDeclared here
getVersionfunctionDeclared here
setContentLengthfunctionDeclared here
getContentLengthfunctionDeclared here
hasContentLengthfunctionDeclared here
setTransferEncodingfunctionDeclared here
getTransferEncodingfunctionDeclared here
setChunkedTransferEncodingfunctionDeclared here
isChunkedTransferEncodingfunctionDeclared here
setContentTypefunctionDeclared here
getContentTypefunctionDeclared here
setKeepAlivefunctionDeclared here
getKeepAlivefunctionDeclared here
writefunctionDeclared here
writefunctionDeclared here
writefunctionDeclared here
HTTP_1_0variableDeclared here
HTTP_1_1variableDeclared here
IDENTITY_TRANSFER_ENCODINGvariableDeclared here
CHUNKED_TRANSFER_ENCODINGvariableDeclared here
UNKNOWN_CONTENT_LENGTHvariableDeclared here
UNKNOWN_CONTENT_TYPEvariableDeclared here
CONTENT_LENGTHvariableDeclared here
CONTENT_TYPEvariableDeclared here
TRANSFER_ENCODINGvariableDeclared here
CONNECTIONvariableDeclared here
CONNECTION_KEEP_ALIVEvariableDeclared here
CONNECTION_CLOSEvariableDeclared here
EMPTYvariableDeclared here
_versionvariableDeclared here
MessagefunctionDeclared here
MessagefunctionDeclared here
~MessagefunctionDeclared here
MaptypedefInherited from NVCollection
IteratortypedefInherited from NVCollection
ConstIteratortypedefInherited from NVCollection
_mapvariableInherited from NVCollection
NVCollectionfunctionInherited from NVCollection
NVCollectionfunctionInherited from NVCollection
NVCollectionfunctionInherited from NVCollection
~NVCollectionfunctionInherited from NVCollection
operator=functionInherited from NVCollection
operator=functionInherited from NVCollection
operator[]functionInherited from NVCollection
setfunctionInherited from NVCollection
addfunctionInherited from NVCollection
addfunctionInherited from NVCollection
getfunctionInherited from NVCollection
getfunctionInherited from NVCollection
hasfunctionInherited from NVCollection
findfunctionInherited from NVCollection
beginfunctionInherited from NVCollection
endfunctionInherited from NVCollection
emptyfunctionInherited from NVCollection
sizefunctionInherited from NVCollection
erasefunctionInherited from NVCollection
clearfunctionInherited from NVCollection

Inherited from NVCollection

KindNameDescription
typedefMap
typedefIterator
typedefConstIterator
variable_map
functionNVCollection inline
functionNVCollection inline
functionNVCollection inline noexcept
function~NVCollection virtual inline
functionoperator=Assigns the name-value pairs of another NVCollection to this one.
functionoperator= noexcept
functionoperator[] constReturns the value of the (first) name-value pair with the given name.
functionsetSets the value of the (first) name-value pair with the given name.
functionaddAdds a new name-value pair with the given name and value.
functionaddAdds a new name-value pair using move semantics.
functionget constReturns the value of the first name-value pair with the given name.
functionget constReturns the value of the first name-value pair with the given name. If no value with the given name has been found, the defaultValue is returned.
functionhas constReturns true if there is at least one name-value pair with the given name.
functionfind constReturns an iterator pointing to the first name-value pair with the given name.
functionbegin constReturns an iterator pointing to the begin of the name-value pair collection.
functionend constReturns an iterator pointing to the end of the name-value pair collection.
functionempty constReturns true iff the header does not have any content.
functionsize constReturns the number of name-value pairs in the collection.
functioneraseRemoves all name-value pairs with the given name.
functionclearRemoves all name-value pairs and their values.

Public Methods

ReturnNameDescription
voidsetVersionSets the HTTP version for this message.
const std::string &getVersion const nodiscardReturns the HTTP version for this message.
voidsetContentLengthSets the Content-Length header.
uint64_tgetContentLength const nodiscardReturns the content length for this message, which may be UNKNOWN_CONTENT_LENGTH if no Content-Length header is present.
boolhasContentLength const nodiscardReturns true if a Content-Length header is present.
voidsetTransferEncodingSets the transfer encoding for this message.
const std::string &getTransferEncoding const nodiscardReturns the transfer encoding used for this message.
voidsetChunkedTransferEncodingIf flag is true, sets the Transfer-Encoding header to chunked. Otherwise, removes the Transfer-Encoding header.
boolisChunkedTransferEncoding const nodiscardReturns true if the Transfer-Encoding header is set and its value is chunked.
voidsetContentTypeSets the content type for this message.
const std::string &getContentType const nodiscardReturns the content type for this message.
voidsetKeepAliveSets the value of the Connection header field.
boolgetKeepAlive const nodiscardReturns true if
voidwrite virtual constWrites the message header to the given output stream.
voidwrite virtual constWrites the message header to the given output string.
voidwrite virtual constWrites the message header directly into a byte buffer.

{#setversion-1}

setVersion

void setVersion(const std::string & version)

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

Sets the HTTP version for this message.


{#getversion-1}

getVersion

const nodiscard

[[nodiscard]] const std::string & getVersion() const

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

Returns the HTTP version for this message.


{#setcontentlength}

setContentLength

void setContentLength(uint64_t length)

Defined in src/http/include/icy/http/message.h:41

Sets the Content-Length header.

If length is UNKNOWN_CONTENT_LENGTH, removes the Content-Length header.


{#getcontentlength}

getContentLength

const nodiscard

[[nodiscard]] uint64_t getContentLength() const

Defined in src/http/include/icy/http/message.h:46

Returns the content length for this message, which may be UNKNOWN_CONTENT_LENGTH if no Content-Length header is present.


{#hascontentlength}

hasContentLength

const nodiscard

[[nodiscard]] bool hasContentLength() const

Defined in src/http/include/icy/http/message.h:49

Returns true if a Content-Length header is present.


{#settransferencoding}

setTransferEncoding

void setTransferEncoding(const std::string & transferEncoding)

Defined in src/http/include/icy/http/message.h:55

Sets the transfer encoding for this message.

The value should be either IDENTITY_TRANSFER_CODING or CHUNKED_TRANSFER_CODING.


{#gettransferencoding}

getTransferEncoding

const nodiscard

[[nodiscard]] const std::string & getTransferEncoding() const

Defined in src/http/include/icy/http/message.h:62

Returns the transfer encoding used for this message.

Normally, this is the value of the Transfer-Encoding header field. If no such field is present, returns IDENTITY_TRANSFER_CODING.


{#setchunkedtransferencoding}

setChunkedTransferEncoding

void setChunkedTransferEncoding(bool flag)

Defined in src/http/include/icy/http/message.h:66

If flag is true, sets the Transfer-Encoding header to chunked. Otherwise, removes the Transfer-Encoding header.


{#ischunkedtransferencoding}

isChunkedTransferEncoding

const nodiscard

[[nodiscard]] bool isChunkedTransferEncoding() const

Defined in src/http/include/icy/http/message.h:70

Returns true if the Transfer-Encoding header is set and its value is chunked.


{#setcontenttype}

setContentType

void setContentType(const std::string & contentType)

Defined in src/http/include/icy/http/message.h:76

Sets the content type for this message.

Specify NO_CONTENT_TYPE to remove the Content-Type header.


{#getcontenttype}

getContentType

const nodiscard

[[nodiscard]] const std::string & getContentType() const

Defined in src/http/include/icy/http/message.h:82

Returns the content type for this message.

If no Content-Type header is present, returns UNKNOWN_CONTENT_TYPE.


{#setkeepalive-1}

setKeepAlive

void setKeepAlive(bool keepAlive)

Defined in src/http/include/icy/http/message.h:88

Sets the value of the Connection header field.

The value is set to "Keep-Alive" if keepAlive is true, or to "Close" otherwise.


{#getkeepalive}

getKeepAlive

const nodiscard

[[nodiscard]] bool getKeepAlive() const

Defined in src/http/include/icy/http/message.h:94

Returns true if

  • the message has a Connection header field and its value is "Keep-Alive"

  • the message is an HTTP/1.1 message and no Connection header is set Returns false otherwise.


{#write-6}

write

virtual const

virtual void write(std::ostream & ostr) const

Defined in src/http/include/icy/http/message.h:102

Writes the message header to the given output stream.

The format is one name-value pair per line, with name and value separated by a colon and lines delimited by a carriage return and a linefeed character. See RFC 2822 for details.

Reimplemented by

{#write-7}

write

virtual const

virtual void write(std::string & str) const

Defined in src/http/include/icy/http/message.h:105

Writes the message header to the given output string.

Reimplemented by

{#write-8}

write

virtual const

virtual void write(Buffer & buf) const

Defined in src/http/include/icy/http/message.h:108

Writes the message header directly into a byte buffer.

Reimplemented by

Public Static Attributes

ReturnNameDescription
const std::stringHTTP_1_0 static
const std::stringHTTP_1_1 static
const std::stringIDENTITY_TRANSFER_ENCODING static
const std::stringCHUNKED_TRANSFER_ENCODING static
const intUNKNOWN_CONTENT_LENGTH static
const std::stringUNKNOWN_CONTENT_TYPE static
const std::stringCONTENT_LENGTH static
const std::stringCONTENT_TYPE static
const std::stringTRANSFER_ENCODING static
const std::stringCONNECTION static
const std::stringCONNECTION_KEEP_ALIVE static
const std::stringCONNECTION_CLOSE static
const std::stringEMPTY static

{#http_1_0}

HTTP_1_0

static

const std::string HTTP_1_0

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


{#http_1_1}

HTTP_1_1

static

const std::string HTTP_1_1

Defined in src/http/include/icy/http/message.h:111


{#identity_transfer_encoding}

IDENTITY_TRANSFER_ENCODING

static

const std::string IDENTITY_TRANSFER_ENCODING

Defined in src/http/include/icy/http/message.h:113


{#chunked_transfer_encoding}

CHUNKED_TRANSFER_ENCODING

static

const std::string CHUNKED_TRANSFER_ENCODING

Defined in src/http/include/icy/http/message.h:114


{#unknown_content_length}

UNKNOWN_CONTENT_LENGTH

static

const int UNKNOWN_CONTENT_LENGTH

Defined in src/http/include/icy/http/message.h:116


{#unknown_content_type}

UNKNOWN_CONTENT_TYPE

static

const std::string UNKNOWN_CONTENT_TYPE

Defined in src/http/include/icy/http/message.h:117


{#content_length}

CONTENT_LENGTH

static

const std::string CONTENT_LENGTH

Defined in src/http/include/icy/http/message.h:119


{#content_type}

CONTENT_TYPE

static

const std::string CONTENT_TYPE

Defined in src/http/include/icy/http/message.h:120


{#transfer_encoding}

TRANSFER_ENCODING

static

const std::string TRANSFER_ENCODING

Defined in src/http/include/icy/http/message.h:121


{#connection-6}

CONNECTION

static

const std::string CONNECTION

Defined in src/http/include/icy/http/message.h:122


{#connection_keep_alive}

CONNECTION_KEEP_ALIVE

static

const std::string CONNECTION_KEEP_ALIVE

Defined in src/http/include/icy/http/message.h:124


{#connection_close}

CONNECTION_CLOSE

static

const std::string CONNECTION_CLOSE

Defined in src/http/include/icy/http/message.h:125


{#empty}

EMPTY

static

const std::string EMPTY

Defined in src/http/include/icy/http/message.h:127

Protected Attributes

ReturnNameDescription
std::string_version

{#_version-1}

_version

std::string _version

Defined in src/http/include/icy/http/message.h:130

Protected Methods

ReturnNameDescription
MessageCreates the Message with version HTTP/1.0.
MessageCreates the Message and sets the version.
~Message virtualDestroys the Message.

{#message-1}

Message

Message()

Defined in src/http/include/icy/http/message.h:133

Creates the Message with version HTTP/1.0.


{#message-2}

Message

Message(const std::string & version)

Defined in src/http/include/icy/http/message.h:137

Creates the Message and sets the version.


{#message-3}

~Message

virtual

virtual ~Message()

Defined in src/http/include/icy/http/message.h:140

Destroys the Message.

{#multipartadapter}

MultipartAdapter

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

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

Inherits: PacketProcessor

HTTP multipart encoding adapter for multipart/x-mixed-replace streaming.

List of all members

NameKindOwner
connectionvariableDeclared here
contentTypevariableDeclared here
isBase64variableDeclared here
initialvariableDeclared here
emittervariableDeclared here
MultipartAdapterfunctionDeclared here
MultipartAdapterfunctionDeclared here
emitHeaderfunctionDeclared here
emitChunkHeaderfunctionDeclared here
processfunctionDeclared here
PacketProcessorfunctionInherited from PacketProcessor
processfunctionInherited from PacketProcessor
acceptsfunctionInherited from PacketProcessor
operator<<functionInherited from PacketProcessor
_emittervariableInherited from PacketStreamAdapter
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
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
variable_emitter
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 const nodiscardReturns 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.
functionPacketStreamAdapterNonCopyable and NonMovable.
functionoperator=Deleted assignment operator.
functionPacketStreamAdapterDeleted constructor.
functionoperator=Deleted assignment operator.

Public Attributes

ReturnNameDescription
Connection::PtrconnectionHTTP connection for sending the initial response header.
std::stringcontentTypeContent-Type of each part (e.g. "image/jpeg").
boolisBase64If true, adds "Content-Transfer-Encoding: base64" to each part.
boolinitialTrue until the first chunk is processed and the boundary header emitted.
PacketSignalemitter

{#connection-7}

connection

Connection::Ptr connection

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

HTTP connection for sending the initial response header.


{#contenttype-2}

contentType

std::string contentType

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

Content-Type of each part (e.g. "image/jpeg").


{#isbase64}

isBase64

bool isBase64

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

If true, adds "Content-Transfer-Encoding: base64" to each part.


{#initial-1}

initial

bool initial

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

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


{#emitter-7}

emitter

PacketSignal emitter

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

Public Methods

ReturnNameDescription
MultipartAdapter inlineCreates a MultipartAdapter that sends headers through the given connection. The per-part content type is read from the connection's outgoing header.
MultipartAdapter inlineCreates a MultipartAdapter 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 with Content-Type multipart/x-mixed-replace. If a connection is set, headers are written through it; otherwise a raw response string is emitted.
voidemitChunkHeader virtual inlineEmits the MIME boundary and per-part headers (Content-Type, optionally Content-Transfer-Encoding) for the next multipart chunk.
voidprocess virtual inlineWraps the incoming packet as a multipart chunk and emits it downstream. Emits the multipart HTTP response headers on the first call.

{#multipartadapter-1}

MultipartAdapter

inline

inline MultipartAdapter(Connection::Ptr connection, bool base64 = false)

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

Creates a MultipartAdapter that sends headers through the given connection. The per-part content type is read from the connection's outgoing header.

Parameters

  • connection HTTP connection to use for sending the initial multipart header.

  • base64 If true, indicates parts are base64-encoded.


{#multipartadapter-2}

MultipartAdapter

inline

inline MultipartAdapter(const std::string & contentType, bool base64 = false)

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

Creates a MultipartAdapter that emits its own raw HTTP/1.1 200 response header. Use this when no Connection object is available.

Parameters

  • contentType Content-Type for each multipart part.

  • base64 If true, indicates parts are base64-encoded.


{#emitheader-1}

emitHeader

virtual inline

virtual inline void emitHeader()

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

Emits the initial HTTP/1.1 200 OK response with Content-Type multipart/x-mixed-replace. If a connection is set, headers are written through it; otherwise a raw response string is emitted.


{#emitchunkheader}

emitChunkHeader

virtual inline

virtual inline void emitChunkHeader()

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

Emits the MIME boundary and per-part headers (Content-Type, optionally Content-Transfer-Encoding) for the next multipart chunk.


{#process-6}

process

virtual inline

virtual inline void process(IPacket & packet)

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

Wraps the incoming packet as a multipart chunk and emits it downstream. Emits the multipart HTTP response headers on the first call.

Parameters

  • packet Packet containing the raw payload data.
Reimplements

{#parser-1}

Parser

#include <icy/http/parser.h>
class Parser

Defined in src/http/include/icy/http/parser.h:55

HTTP request/response parser using the llhttp library.

List of all members

NameKindOwner
ParserfunctionDeclared here
ParserfunctionDeclared here
ParserfunctionDeclared here
ParserfunctionDeclared here
ParserfunctionDeclared here
parsefunctionDeclared here
resetfunctionDeclared here
resetStatefunctionDeclared here
completefunctionDeclared here
upgradefunctionDeclared here
typefunctionDeclared here
setRequestfunctionDeclared here
setResponsefunctionDeclared here
setObserverfunctionDeclared here
clearMessagefunctionDeclared here
messagefunctionDeclared here
observerfunctionDeclared here
_observervariableDeclared here
_requestvariableDeclared here
_responsevariableDeclared here
_messagevariableDeclared here
_parservariableDeclared here
_settingsvariableDeclared here
_typevariableDeclared here
_wasHeaderValuevariableDeclared here
_lastHeaderFieldvariableDeclared here
_lastHeaderValuevariableDeclared here
_completevariableDeclared here
_upgradevariableDeclared here
_errorvariableDeclared here
_lastResultvariableDeclared here
_scratchvariableDeclared here
initfunctionDeclared here
clearBoundMessagefunctionDeclared here
storeHeaderfunctionDeclared here
applyScratchToBoundMessagefunctionDeclared here
onHeaderfunctionDeclared here
onHeadersEndfunctionDeclared here
onBodyfunctionDeclared here
onMessageEndfunctionDeclared here
onErrorfunctionDeclared here

Public Methods

ReturnNameDescription
ParserCreates a response parser. The response object is populated as data is parsed.
ParserCreates a request parser. The request object is populated as data is parsed.
ParserCreates a parser of the given type without binding a message object.
ParserDeleted constructor.
ParserDeleted constructor.
ParseResultparseFeeds a buffer of raw HTTP data into the parser.
voidresetReset the internal state (reinitialises llhttp). Safe to call externally, NOT from inside llhttp callbacks.
voidresetStateReset internal flags without reinitialising llhttp. Safe to call from inside llhttp callbacks (e.g. on_message_begin).
boolcomplete const nodiscardReturns true if parsing is complete, either in success or error.
boolupgrade const nodiscardReturns true if the connection should be upgraded.
llhttp_type_ttype const inline nodiscardReturns the parser type (HTTP_REQUEST or HTTP_RESPONSE).
voidsetRequestBinds an HTTP request object to populate during parsing. Must only be called when no message is currently set and type is HTTP_REQUEST.
voidsetResponseBinds an HTTP response object to populate during parsing. Must only be called when no message is currently set and type is HTTP_RESPONSE.
voidsetObserverSets the observer that receives parser events.
voidclearMessageClear request/response pointers so they can be re-set. Used when resetting a pooled connection for reuse.
http::Message *message nodiscardReturns the currently bound message (request or response), or nullptr.
ParserObserver *observer const nodiscardReturns the current parser observer, or nullptr if none is set.

{#parser-2}

Parser

Parser(http::Response * response)

Defined in src/http/include/icy/http/parser.h:70

Creates a response parser. The response object is populated as data is parsed.

Parameters

  • response HTTP response object to populate.

{#parser-3}

Parser

Parser(http::Request * request)

Defined in src/http/include/icy/http/parser.h:74

Creates a request parser. The request object is populated as data is parsed.

Parameters

  • request HTTP request object to populate.

{#parser-4}

Parser

Parser(llhttp_type_t type)

Defined in src/http/include/icy/http/parser.h:78

Creates a parser of the given type without binding a message object.

Parameters

  • type Either HTTP_REQUEST or HTTP_RESPONSE.

{#parser-5}

Parser

Parser(const Parser &) = delete

Defined in src/http/include/icy/http/parser.h:81

Deleted constructor.


{#parser-6}

Parser

Parser(Parser &&) = delete

Defined in src/http/include/icy/http/parser.h:83

Deleted constructor.


{#parse}

parse

ParseResult parse(const char * data, size_t length)

Defined in src/http/include/icy/http/parser.h:93

Feeds a buffer of raw HTTP data into the parser.

May be called multiple times for streaming data. The parser state persists between calls. On completion or error, the observer is notified.

Parameters

  • data Pointer to the input data buffer.

  • length Number of bytes in the buffer.

Returns

Structured parse result including bytes consumed and terminal state.


{#reset-10}

reset

void reset()

Defined in src/http/include/icy/http/parser.h:97

Reset the internal state (reinitialises llhttp). Safe to call externally, NOT from inside llhttp callbacks.


{#resetstate}

resetState

void resetState()

Defined in src/http/include/icy/http/parser.h:101

Reset internal flags without reinitialising llhttp. Safe to call from inside llhttp callbacks (e.g. on_message_begin).


{#complete-2}

complete

const nodiscard

[[nodiscard]] bool complete() const

Defined in src/http/include/icy/http/parser.h:105

Returns true if parsing is complete, either in success or error.


{#upgrade}

upgrade

const nodiscard

[[nodiscard]] bool upgrade() const

Defined in src/http/include/icy/http/parser.h:108

Returns true if the connection should be upgraded.


{#type-9}

type

const inline nodiscard

[[nodiscard]] inline llhttp_type_t type() const

Defined in src/http/include/icy/http/parser.h:111

Returns the parser type (HTTP_REQUEST or HTTP_RESPONSE).


{#setrequest}

setRequest

void setRequest(http::Request * request)

Defined in src/http/include/icy/http/parser.h:116

Binds an HTTP request object to populate during parsing. Must only be called when no message is currently set and type is HTTP_REQUEST.

Parameters

  • request The request object to populate.

{#setresponse}

setResponse

void setResponse(http::Response * response)

Defined in src/http/include/icy/http/parser.h:121

Binds an HTTP response object to populate during parsing. Must only be called when no message is currently set and type is HTTP_RESPONSE.

Parameters

  • response The response object to populate.

{#setobserver}

setObserver

void setObserver(ParserObserver * observer)

Defined in src/http/include/icy/http/parser.h:125

Sets the observer that receives parser events.

Parameters

  • observer Observer to notify. May be nullptr to clear.

{#clearmessage}

clearMessage

void clearMessage()

Defined in src/http/include/icy/http/parser.h:129

Clear request/response pointers so they can be re-set. Used when resetting a pooled connection for reuse.


{#message-4}

message

nodiscard

[[nodiscard]] http::Message * message()

Defined in src/http/include/icy/http/parser.h:132

Returns the currently bound message (request or response), or nullptr.


{#observer}

observer

const nodiscard

[[nodiscard]] ParserObserver * observer() const

Defined in src/http/include/icy/http/parser.h:135

Returns the current parser observer, or nullptr if none is set.

Protected Attributes

ReturnNameDescription
ParserObserver *_observer
http::Request *_request
http::Response *_response
http::Message *_message
llhttp_t_parser
llhttp_settings_t_settings
llhttp_type_t_type
bool_wasHeaderValue
std::string_lastHeaderField
std::string_lastHeaderValue
bool_complete
bool_upgrade
Error_error
ParseResult_lastResult
MessageScratch_scratch

{#_observer}

_observer

ParserObserver * _observer

Defined in src/http/include/icy/http/parser.h:181


{#_request-1}

_request

http::Request * _request

Defined in src/http/include/icy/http/parser.h:182


{#_response-1}

_response

http::Response * _response

Defined in src/http/include/icy/http/parser.h:183


{#_message}

_message

http::Message * _message

Defined in src/http/include/icy/http/parser.h:184


{#_parser-1}

_parser

llhttp_t _parser

Defined in src/http/include/icy/http/parser.h:186


{#_settings}

_settings

llhttp_settings_t _settings

Defined in src/http/include/icy/http/parser.h:187


{#_type}

_type

llhttp_type_t _type

Defined in src/http/include/icy/http/parser.h:188


{#_washeadervalue}

_wasHeaderValue

bool _wasHeaderValue

Defined in src/http/include/icy/http/parser.h:190


{#_lastheaderfield}

_lastHeaderField

std::string _lastHeaderField

Defined in src/http/include/icy/http/parser.h:191


{#_lastheadervalue}

_lastHeaderValue

std::string _lastHeaderValue

Defined in src/http/include/icy/http/parser.h:192


{#_complete-2}

_complete

bool _complete

Defined in src/http/include/icy/http/parser.h:194


{#_upgrade}

_upgrade

bool _upgrade

Defined in src/http/include/icy/http/parser.h:195


{#_error-3}

_error

Error _error

Defined in src/http/include/icy/http/parser.h:197


{#_lastresult}

_lastResult

ParseResult _lastResult

Defined in src/http/include/icy/http/parser.h:198


{#_scratch}

_scratch

MessageScratch _scratch

Defined in src/http/include/icy/http/parser.h:199

Protected Methods

ReturnNameDescription
voidinit
voidclearBoundMessage
voidstoreHeader
voidapplyScratchToBoundMessage
voidonHeaderCallbacks.
voidonHeadersEnd
voidonBody
voidonMessageEnd
voidonError

{#init-8}

init

void init()

Defined in src/http/include/icy/http/parser.h:158


{#clearboundmessage}

clearBoundMessage

void clearBoundMessage()

Defined in src/http/include/icy/http/parser.h:159


{#storeheader}

storeHeader

void storeHeader(std::string name, std::string value)

Defined in src/http/include/icy/http/parser.h:160


{#applyscratchtoboundmessage}

applyScratchToBoundMessage

void applyScratchToBoundMessage()

Defined in src/http/include/icy/http/parser.h:161


{#onheader}

onHeader

void onHeader(std::string name, std::string value)

Defined in src/http/include/icy/http/parser.h:164

Callbacks.


{#onheadersend}

onHeadersEnd

void onHeadersEnd()

Defined in src/http/include/icy/http/parser.h:165


{#onbody}

onBody

void onBody(const char * buf, size_t len)

Defined in src/http/include/icy/http/parser.h:166


{#onmessageend}

onMessageEnd

void onMessageEnd()

Defined in src/http/include/icy/http/parser.h:167


{#onerror-3}

onError

void onError(llhttp_errno_t errnum, const std::string & message = "")

Defined in src/http/include/icy/http/parser.h:168

{#parseresult}

ParseResult

#include <icy/http/parser.h>
struct ParseResult

Defined in src/http/include/icy/http/parser.h:58

List of all members

NameKindOwner
bytesConsumedvariableDeclared here
messageCompletevariableDeclared here
upgradevariableDeclared here
errorvariableDeclared here
okfunctionDeclared here

Public Attributes

ReturnNameDescription
size_tbytesConsumed
boolmessageComplete
boolupgrade
Errorerror

{#bytesconsumed}

bytesConsumed

size_t bytesConsumed = 0

Defined in src/http/include/icy/http/parser.h:60


{#messagecomplete}

messageComplete

bool messageComplete = false

Defined in src/http/include/icy/http/parser.h:61


{#upgrade-1}

upgrade

bool upgrade = false

Defined in src/http/include/icy/http/parser.h:62


{#error-11}

error

Error error

Defined in src/http/include/icy/http/parser.h:63

Public Methods

ReturnNameDescription
boolok const inline nodiscard

{#ok}

ok

const inline nodiscard

[[nodiscard]] inline bool ok() const

Defined in src/http/include/icy/http/parser.h:65

{#messagescratch}

MessageScratch

#include <icy/http/parser.h>
struct MessageScratch

Defined in src/http/include/icy/http/parser.h:138

List of all members

NameKindOwner
versionvariableDeclared here
methodvariableDeclared here
urivariableDeclared here
reasonvariableDeclared here
statusvariableDeclared here
headersvariableDeclared here
resetfunctionDeclared here

Public Attributes

ReturnNameDescription
std::stringversion
std::stringmethod
std::stringuri
std::stringreason
http::StatusCodestatus
std::vector< std::pair< std::string, std::string > >headers

{#version-2}

version

std::string version

Defined in src/http/include/icy/http/parser.h:140


{#method-1}

method

std::string method

Defined in src/http/include/icy/http/parser.h:141


{#uri}

uri

std::string uri

Defined in src/http/include/icy/http/parser.h:142


{#reason}

reason

std::string reason

Defined in src/http/include/icy/http/parser.h:143


{#status-2}

status

http::StatusCode status = 

Defined in src/http/include/icy/http/parser.h:144


{#headers-2}

headers

std::vector< std::pair< std::string, std::string > > headers

Defined in src/http/include/icy/http/parser.h:145

Public Methods

ReturnNameDescription
voidreset inline

{#reset-11}

reset

inline

inline void reset()

Defined in src/http/include/icy/http/parser.h:147

{#parserobserver}

ParserObserver

#include <icy/http/parser.h>
class ParserObserver

Defined in src/http/include/icy/http/parser.h:27

Subclassed by: ConnectionAdapter

Abstract observer interface for HTTP parser events.

List of all members

NameKindOwner
onParserHeaderfunctionDeclared here
onParserHeadersEndfunctionDeclared here
onParserChunkfunctionDeclared here
onParserEndfunctionDeclared here
onParserErrorfunctionDeclared here

Public Methods

ReturnNameDescription
voidonParserHeader virtualCalled for each parsed HTTP header name/value pair.
voidonParserHeadersEnd virtualCalled when all HTTP headers have been parsed.
voidonParserChunk virtualCalled for each chunk of body data received.
voidonParserEnd virtualCalled when the HTTP message is fully parsed.
voidonParserError virtualCalled when a parse error occurs.

{#onparserheader-1}

onParserHeader

virtual

virtual void onParserHeader(const std::string & name, const std::string & value)

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

Called for each parsed HTTP header name/value pair.

Parameters

  • name Header field name.

  • value Header field value.

Reimplemented by

{#onparserheadersend-1}

onParserHeadersEnd

virtual

virtual void onParserHeadersEnd(bool upgrade)

Defined in src/http/include/icy/http/parser.h:37

Called when all HTTP headers have been parsed.

Parameters

  • upgrade True if the connection should be upgraded (e.g. to WebSocket).
Reimplemented by

{#onparserchunk-1}

onParserChunk

virtual

virtual void onParserChunk(const char * data, size_t len)

Defined in src/http/include/icy/http/parser.h:42

Called for each chunk of body data received.

Parameters

  • data Pointer to the body data chunk.

  • len Length of the chunk in bytes.

Reimplemented by

{#onparserend-1}

onParserEnd

virtual

virtual void onParserEnd()

Defined in src/http/include/icy/http/parser.h:45

Called when the HTTP message is fully parsed.

Reimplemented by

{#onparsererror-1}

onParserError

virtual

virtual void onParserError(const Error & err)

Defined in src/http/include/icy/http/parser.h:49

Called when a parse error occurs.

Parameters

  • err Error details from llhttp.
Reimplemented by

{#progresssignal}

ProgressSignal

#include <icy/http/connection.h>
class ProgressSignal

Defined in src/http/include/icy/http/connection.h:223

Inherits: Signal< void(const double &)>

HTTP progress signal for upload and download progress notifications.

Emits a double in the range [0, 100] as data is transferred. Set [total](#total-1) to the expected byte count before calling [update()](#update-1).

List of all members

NameKindOwner
sendervariableDeclared here
currentvariableDeclared here
totalvariableDeclared here
ProgressSignalfunctionDeclared here
progressfunctionDeclared here
updatefunctionDeclared here

Public Attributes

ReturnNameDescription
void *senderOptional context pointer identifying the sender.
uint64_tcurrentBytes transferred so far.
uint64_ttotalTotal expected bytes (from Content-Length).

{#sender-1}

sender

void * sender

Defined in src/http/include/icy/http/connection.h:226

Optional context pointer identifying the sender.


{#current-1}

current

uint64_t current

Defined in src/http/include/icy/http/connection.h:227

Bytes transferred so far.


{#total-1}

total

uint64_t total

Defined in src/http/include/icy/http/connection.h:228

Total expected bytes (from Content-Length).

Public Methods

ReturnNameDescription
ProgressSignal inline
doubleprogress const inline nodiscardReturns the current transfer progress as a percentage (0-100).
voidupdate inlineAdvances the progress counter by nread bytes and emits the updated percentage.

{#progresssignal-1}

ProgressSignal

inline

inline ProgressSignal()

Defined in src/http/include/icy/http/connection.h:230


{#progress}

progress

const inline nodiscard

[[nodiscard]] inline double progress() const

Defined in src/http/include/icy/http/connection.h:238

Returns the current transfer progress as a percentage (0-100).


{#update-1}

update

inline

inline void update(int nread)

Defined in src/http/include/icy/http/connection.h:243

Advances the progress counter by nread bytes and emits the updated percentage.

Parameters

  • nread Number of bytes just transferred.

Exceptions

  • std::runtime_error if current would exceed total.

{#request-4}

Request

#include <icy/http/request.h>
class Request

Defined in src/http/include/icy/http/request.h:44

Inherits: Message

HTTP request message with method, URI, headers, and optional body.

In addition to the properties common to all HTTP messages, an HTTP request has a method (e.g. GET, HEAD, POST, etc.) and a request URI.

List of all members

NameKindOwner
operator<<friendDeclared here
RequestfunctionDeclared here
RequestfunctionDeclared here
RequestfunctionDeclared here
RequestfunctionDeclared here
~RequestfunctionDeclared here
setMethodfunctionDeclared here
getMethodfunctionDeclared here
setURIfunctionDeclared here
appendURIfunctionDeclared here
getURIfunctionDeclared here
setHostfunctionDeclared here
setHostfunctionDeclared here
getHostfunctionDeclared here
setCookiesfunctionDeclared here
getCookiesfunctionDeclared here
getURIParametersfunctionDeclared here
hasCredentialsfunctionDeclared here
getCredentialsfunctionDeclared here
setCredentialsfunctionDeclared here
hasProxyCredentialsfunctionDeclared here
getProxyCredentialsfunctionDeclared here
setProxyCredentialsfunctionDeclared here
writefunctionDeclared here
writefunctionDeclared here
writefunctionDeclared here
getCredentialsfunctionDeclared here
setCredentialsfunctionDeclared here
_methodvariableDeclared here
_urivariableDeclared here
setVersionfunctionInherited from Message
getVersionfunctionInherited from Message
setContentLengthfunctionInherited from Message
getContentLengthfunctionInherited from Message
hasContentLengthfunctionInherited from Message
setTransferEncodingfunctionInherited from Message
getTransferEncodingfunctionInherited from Message
setChunkedTransferEncodingfunctionInherited from Message
isChunkedTransferEncodingfunctionInherited from Message
setContentTypefunctionInherited from Message
getContentTypefunctionInherited from Message
setKeepAlivefunctionInherited from Message
getKeepAlivefunctionInherited from Message
writefunctionInherited from Message
writefunctionInherited from Message
writefunctionInherited from Message
HTTP_1_0variableInherited from Message
HTTP_1_1variableInherited from Message
IDENTITY_TRANSFER_ENCODINGvariableInherited from Message
CHUNKED_TRANSFER_ENCODINGvariableInherited from Message
UNKNOWN_CONTENT_LENGTHvariableInherited from Message
UNKNOWN_CONTENT_TYPEvariableInherited from Message
CONTENT_LENGTHvariableInherited from Message
CONTENT_TYPEvariableInherited from Message
TRANSFER_ENCODINGvariableInherited from Message
CONNECTIONvariableInherited from Message
CONNECTION_KEEP_ALIVEvariableInherited from Message
CONNECTION_CLOSEvariableInherited from Message
EMPTYvariableInherited from Message
_versionvariableInherited from Message
MessagefunctionInherited from Message
MessagefunctionInherited from Message
~MessagefunctionInherited from Message
MaptypedefInherited from NVCollection
IteratortypedefInherited from NVCollection
ConstIteratortypedefInherited from NVCollection
_mapvariableInherited from NVCollection
NVCollectionfunctionInherited from NVCollection
NVCollectionfunctionInherited from NVCollection
NVCollectionfunctionInherited from NVCollection
~NVCollectionfunctionInherited from NVCollection
operator=functionInherited from NVCollection
operator=functionInherited from NVCollection
operator[]functionInherited from NVCollection
setfunctionInherited from NVCollection
addfunctionInherited from NVCollection
addfunctionInherited from NVCollection
getfunctionInherited from NVCollection
getfunctionInherited from NVCollection
hasfunctionInherited from NVCollection
findfunctionInherited from NVCollection
beginfunctionInherited from NVCollection
endfunctionInherited from NVCollection
emptyfunctionInherited from NVCollection
sizefunctionInherited from NVCollection
erasefunctionInherited from NVCollection
clearfunctionInherited from NVCollection

Inherited from Message

KindNameDescription
functionsetVersionSets the HTTP version for this message.
functiongetVersion const nodiscardReturns the HTTP version for this message.
functionsetContentLengthSets the Content-Length header.
functiongetContentLength const nodiscardReturns the content length for this message, which may be UNKNOWN_CONTENT_LENGTH if no Content-Length header is present.
functionhasContentLength const nodiscardReturns true if a Content-Length header is present.
functionsetTransferEncodingSets the transfer encoding for this message.
functiongetTransferEncoding const nodiscardReturns the transfer encoding used for this message.
functionsetChunkedTransferEncodingIf flag is true, sets the Transfer-Encoding header to chunked. Otherwise, removes the Transfer-Encoding header.
functionisChunkedTransferEncoding const nodiscardReturns true if the Transfer-Encoding header is set and its value is chunked.
functionsetContentTypeSets the content type for this message.
functiongetContentType const nodiscardReturns the content type for this message.
functionsetKeepAliveSets the value of the Connection header field.
functiongetKeepAlive const nodiscardReturns true if
functionwrite virtual constWrites the message header to the given output stream.
functionwrite virtual constWrites the message header to the given output string.
functionwrite virtual constWrites the message header directly into a byte buffer.
variableHTTP_1_0 static
variableHTTP_1_1 static
variableIDENTITY_TRANSFER_ENCODING static
variableCHUNKED_TRANSFER_ENCODING static
variableUNKNOWN_CONTENT_LENGTH static
variableUNKNOWN_CONTENT_TYPE static
variableCONTENT_LENGTH static
variableCONTENT_TYPE static
variableTRANSFER_ENCODING static
variableCONNECTION static
variableCONNECTION_KEEP_ALIVE static
variableCONNECTION_CLOSE static
variableEMPTY static
variable_version
functionMessageCreates the Message with version HTTP/1.0.
functionMessageCreates the Message and sets the version.
function~Message virtualDestroys the Message.

Inherited from NVCollection

KindNameDescription
typedefMap
typedefIterator
typedefConstIterator
variable_map
functionNVCollection inline
functionNVCollection inline
functionNVCollection inline noexcept
function~NVCollection virtual inline
functionoperator=Assigns the name-value pairs of another NVCollection to this one.
functionoperator= noexcept
functionoperator[] constReturns the value of the (first) name-value pair with the given name.
functionsetSets the value of the (first) name-value pair with the given name.
functionaddAdds a new name-value pair with the given name and value.
functionaddAdds a new name-value pair using move semantics.
functionget constReturns the value of the first name-value pair with the given name.
functionget constReturns the value of the first name-value pair with the given name. If no value with the given name has been found, the defaultValue is returned.
functionhas constReturns true if there is at least one name-value pair with the given name.
functionfind constReturns an iterator pointing to the first name-value pair with the given name.
functionbegin constReturns an iterator pointing to the begin of the name-value pair collection.
functionend constReturns an iterator pointing to the end of the name-value pair collection.
functionempty constReturns true iff the header does not have any content.
functionsize constReturns the number of name-value pairs in the collection.
functioneraseRemoves all name-value pairs with the given name.
functionclearRemoves all name-value pairs and their values.

Friends

NameDescription
operator<< inline

{#operator-17}

operator<<

inline

friend inline std::ostream & operator<<(std::ostream & stream, const Request & req)

Defined in src/http/include/icy/http/request.h:146

Public Methods

ReturnNameDescription
RequestCreates a GET / HTTP/1.1 HTTP request.
RequestCreates a GET / HTTP/1.x request with the given version (HTTP/1.0 or HTTP/1.1).
RequestCreates an HTTP/1.0 request with the given method and URI.
RequestCreates an HTTP request with the given method, URI and version.
~Request virtualDestroys the Request.
voidsetMethodSets the method.
const std::string &getMethod const nodiscardReturns the method.
voidsetURISets the request URI.
voidappendURIAppends a fragment to the request URI. Used by the parser when llhttp splits the URL across callbacks.
const std::string &getURI const nodiscardReturns the request URI.
voidsetHostSets the value of the Host header field.
voidsetHostSets the value of the Host header field.
const std::string &getHost const nodiscardReturns the value of the Host header field.
voidsetCookiesAdds a Cookie header with the names and values from cookies.
voidgetCookies constFills cookies with the cookies extracted from the Cookie headers in the request.
voidgetURIParameters constReturns the request URI parameters.
boolhasCredentials const nodiscardReturns true if the request contains authentication information in the form of an Authorization header.
voidgetCredentials constReturns the authentication scheme and additional authentication information contained in this request.
voidsetCredentialsSets the authentication scheme and information for this request.
boolhasProxyCredentials const nodiscardReturns true if the request contains proxy authentication information in the form of an Proxy-Authorization header.
voidgetProxyCredentials constReturns the proxy authentication scheme and additional proxy authentication information contained in this request.
voidsetProxyCredentialsSets the proxy authentication scheme and information for this request.
voidwrite virtual constWrites the HTTP request to the given output stream.
voidwrite virtual constWrites the HTTP request to the given output string.
voidwrite virtual constWrites the HTTP request directly into a byte buffer.

{#request-5}

Request

Request()

Defined in src/http/include/icy/http/request.h:48

Creates a GET / HTTP/1.1 HTTP request.


{#request-6}

Request

Request(const std::string & version)

Defined in src/http/include/icy/http/request.h:52

Creates a GET / HTTP/1.x request with the given version (HTTP/1.0 or HTTP/1.1).


{#request-7}

Request

Request(const std::string & method, const std::string & uri)

Defined in src/http/include/icy/http/request.h:55

Creates an HTTP/1.0 request with the given method and URI.


{#request-8}

Request

Request(const std::string & method, const std::string & uri, const std::string & version)

Defined in src/http/include/icy/http/request.h:58

Creates an HTTP request with the given method, URI and version.


{#request-9}

~Request

virtual

virtual ~Request()

Defined in src/http/include/icy/http/request.h:61

Destroys the Request.


{#setmethod}

setMethod

void setMethod(const std::string & method)

Defined in src/http/include/icy/http/request.h:64

Sets the method.


{#getmethod}

getMethod

const nodiscard

[[nodiscard]] const std::string & getMethod() const

Defined in src/http/include/icy/http/request.h:67

Returns the method.


{#seturi}

setURI

void setURI(std::string uri)

Defined in src/http/include/icy/http/request.h:70

Sets the request URI.


{#appenduri}

appendURI

void appendURI(std::string_view uri)

Defined in src/http/include/icy/http/request.h:74

Appends a fragment to the request URI. Used by the parser when llhttp splits the URL across callbacks.


{#geturi}

getURI

const nodiscard

[[nodiscard]] const std::string & getURI() const

Defined in src/http/include/icy/http/request.h:77

Returns the request URI.


{#sethost}

setHost

void setHost(const std::string & host)

Defined in src/http/include/icy/http/request.h:80

Sets the value of the Host header field.


{#sethost-1}

setHost

void setHost(const std::string & host, uint16_t port)

Defined in src/http/include/icy/http/request.h:87

Sets the value of the Host header field.

If the given port number is a non-standard port number (other than 80 or 443), it is included in the Host header field.


{#gethost}

getHost

const nodiscard

[[nodiscard]] const std::string & getHost() const

Defined in src/http/include/icy/http/request.h:93

Returns the value of the Host header field.

Throws a NotFoundException if the request does not have a Host header field.


{#setcookies}

setCookies

void setCookies(const NVCollection & cookies)

Defined in src/http/include/icy/http/request.h:97

Adds a Cookie header with the names and values from cookies.


{#getcookies}

getCookies

const

void getCookies(NVCollection & cookies) const

Defined in src/http/include/icy/http/request.h:101

Fills cookies with the cookies extracted from the Cookie headers in the request.


{#geturiparameters}

getURIParameters

const

void getURIParameters(NVCollection & params) const

Defined in src/http/include/icy/http/request.h:104

Returns the request URI parameters.


{#hascredentials}

hasCredentials

const nodiscard

[[nodiscard]] bool hasCredentials() const

Defined in src/http/include/icy/http/request.h:108

Returns true if the request contains authentication information in the form of an Authorization header.


{#getcredentials}

getCredentials

const

void getCredentials(std::string & scheme, std::string & authInfo) const

Defined in src/http/include/icy/http/request.h:115

Returns the authentication scheme and additional authentication information contained in this request.

Throws a std::exception if no authentication information is contained in the request.


{#setcredentials}

setCredentials

void setCredentials(std::string_view scheme, std::string_view authInfo)

Defined in src/http/include/icy/http/request.h:119

Sets the authentication scheme and information for this request.


{#hasproxycredentials}

hasProxyCredentials

const nodiscard

[[nodiscard]] bool hasProxyCredentials() const

Defined in src/http/include/icy/http/request.h:123

Returns true if the request contains proxy authentication information in the form of an Proxy-Authorization header.


{#getproxycredentials}

getProxyCredentials

const

void getProxyCredentials(std::string & scheme, std::string & authInfo) const

Defined in src/http/include/icy/http/request.h:131

Returns the proxy authentication scheme and additional proxy authentication information contained in this request.

Throws a std::exception if no proxy authentication information is contained in the request.


{#setproxycredentials}

setProxyCredentials

void setProxyCredentials(std::string_view scheme, std::string_view authInfo)

Defined in src/http/include/icy/http/request.h:134

Sets the proxy authentication scheme and information for this request.


{#write-9}

write

virtual const

virtual void write(std::ostream & ostr) const

Defined in src/http/include/icy/http/request.h:138

Writes the HTTP request to the given output stream.

Reimplements

{#write-10}

write

virtual const

virtual void write(std::string & str) const

Defined in src/http/include/icy/http/request.h:141

Writes the HTTP request to the given output string.

Reimplements

{#write-11}

write

virtual const

virtual void write(Buffer & buf) const

Defined in src/http/include/icy/http/request.h:144

Writes the HTTP request directly into a byte buffer.

Reimplements

Protected Methods

ReturnNameDescription
voidgetCredentials constReturns the authentication scheme and additional authentication information contained in the given header of request.
voidsetCredentialsWrites the authentication scheme and information for this request to the given header.

{#getcredentials-1}

getCredentials

const

void getCredentials(const std::string & header, std::string & scheme, std::string & authInfo) const

Defined in src/http/include/icy/http/request.h:158

Returns the authentication scheme and additional authentication information contained in the given header of request.

Throws a NotAuthenticatedException if no authentication information is contained in the request.


{#setcredentials-1}

setCredentials

void setCredentials(const std::string & header, std::string_view scheme, std::string_view authInfo)

Defined in src/http/include/icy/http/request.h:162

Writes the authentication scheme and information for this request to the given header.

Private Attributes

ReturnNameDescription
std::string_method
std::string_uri

{#_method}

_method

std::string _method

Defined in src/http/include/icy/http/request.h:165


{#_uri}

_uri

std::string _uri

Defined in src/http/include/icy/http/request.h:166

{#response-1}

Response

#include <icy/http/response.h>
class Response

Defined in src/http/include/icy/http/response.h:78

Inherits: Message

HTTP response message with status, reason phrase, headers, and body metadata.

List of all members

NameKindOwner
operator<<friendDeclared here
ResponsefunctionDeclared here
ResponsefunctionDeclared here
ResponsefunctionDeclared here
ResponsefunctionDeclared here
ResponsefunctionDeclared here
~ResponsefunctionDeclared here
setStatusfunctionDeclared here
getStatusfunctionDeclared here
setReasonfunctionDeclared here
getReasonfunctionDeclared here
setStatusAndReasonfunctionDeclared here
setDatefunctionDeclared here
getDatefunctionDeclared here
addCookiefunctionDeclared here
getCookiesfunctionDeclared here
writefunctionDeclared here
writefunctionDeclared here
writefunctionDeclared here
successfunctionDeclared here
_statusvariableDeclared here
_reasonvariableDeclared here
setVersionfunctionInherited from Message
getVersionfunctionInherited from Message
setContentLengthfunctionInherited from Message
getContentLengthfunctionInherited from Message
hasContentLengthfunctionInherited from Message
setTransferEncodingfunctionInherited from Message
getTransferEncodingfunctionInherited from Message
setChunkedTransferEncodingfunctionInherited from Message
isChunkedTransferEncodingfunctionInherited from Message
setContentTypefunctionInherited from Message
getContentTypefunctionInherited from Message
setKeepAlivefunctionInherited from Message
getKeepAlivefunctionInherited from Message
writefunctionInherited from Message
writefunctionInherited from Message
writefunctionInherited from Message
HTTP_1_0variableInherited from Message
HTTP_1_1variableInherited from Message
IDENTITY_TRANSFER_ENCODINGvariableInherited from Message
CHUNKED_TRANSFER_ENCODINGvariableInherited from Message
UNKNOWN_CONTENT_LENGTHvariableInherited from Message
UNKNOWN_CONTENT_TYPEvariableInherited from Message
CONTENT_LENGTHvariableInherited from Message
CONTENT_TYPEvariableInherited from Message
TRANSFER_ENCODINGvariableInherited from Message
CONNECTIONvariableInherited from Message
CONNECTION_KEEP_ALIVEvariableInherited from Message
CONNECTION_CLOSEvariableInherited from Message
EMPTYvariableInherited from Message
_versionvariableInherited from Message
MessagefunctionInherited from Message
MessagefunctionInherited from Message
~MessagefunctionInherited from Message
MaptypedefInherited from NVCollection
IteratortypedefInherited from NVCollection
ConstIteratortypedefInherited from NVCollection
_mapvariableInherited from NVCollection
NVCollectionfunctionInherited from NVCollection
NVCollectionfunctionInherited from NVCollection
NVCollectionfunctionInherited from NVCollection
~NVCollectionfunctionInherited from NVCollection
operator=functionInherited from NVCollection
operator=functionInherited from NVCollection
operator[]functionInherited from NVCollection
setfunctionInherited from NVCollection
addfunctionInherited from NVCollection
addfunctionInherited from NVCollection
getfunctionInherited from NVCollection
getfunctionInherited from NVCollection
hasfunctionInherited from NVCollection
findfunctionInherited from NVCollection
beginfunctionInherited from NVCollection
endfunctionInherited from NVCollection
emptyfunctionInherited from NVCollection
sizefunctionInherited from NVCollection
erasefunctionInherited from NVCollection
clearfunctionInherited from NVCollection

Inherited from Message

KindNameDescription
functionsetVersionSets the HTTP version for this message.
functiongetVersion const nodiscardReturns the HTTP version for this message.
functionsetContentLengthSets the Content-Length header.
functiongetContentLength const nodiscardReturns the content length for this message, which may be UNKNOWN_CONTENT_LENGTH if no Content-Length header is present.
functionhasContentLength const nodiscardReturns true if a Content-Length header is present.
functionsetTransferEncodingSets the transfer encoding for this message.
functiongetTransferEncoding const nodiscardReturns the transfer encoding used for this message.
functionsetChunkedTransferEncodingIf flag is true, sets the Transfer-Encoding header to chunked. Otherwise, removes the Transfer-Encoding header.
functionisChunkedTransferEncoding const nodiscardReturns true if the Transfer-Encoding header is set and its value is chunked.
functionsetContentTypeSets the content type for this message.
functiongetContentType const nodiscardReturns the content type for this message.
functionsetKeepAliveSets the value of the Connection header field.
functiongetKeepAlive const nodiscardReturns true if
functionwrite virtual constWrites the message header to the given output stream.
functionwrite virtual constWrites the message header to the given output string.
functionwrite virtual constWrites the message header directly into a byte buffer.
variableHTTP_1_0 static
variableHTTP_1_1 static
variableIDENTITY_TRANSFER_ENCODING static
variableCHUNKED_TRANSFER_ENCODING static
variableUNKNOWN_CONTENT_LENGTH static
variableUNKNOWN_CONTENT_TYPE static
variableCONTENT_LENGTH static
variableCONTENT_TYPE static
variableTRANSFER_ENCODING static
variableCONNECTION static
variableCONNECTION_KEEP_ALIVE static
variableCONNECTION_CLOSE static
variableEMPTY static
variable_version
functionMessageCreates the Message with version HTTP/1.0.
functionMessageCreates the Message and sets the version.
function~Message virtualDestroys the Message.

Inherited from NVCollection

KindNameDescription
typedefMap
typedefIterator
typedefConstIterator
variable_map
functionNVCollection inline
functionNVCollection inline
functionNVCollection inline noexcept
function~NVCollection virtual inline
functionoperator=Assigns the name-value pairs of another NVCollection to this one.
functionoperator= noexcept
functionoperator[] constReturns the value of the (first) name-value pair with the given name.
functionsetSets the value of the (first) name-value pair with the given name.
functionaddAdds a new name-value pair with the given name and value.
functionaddAdds a new name-value pair using move semantics.
functionget constReturns the value of the first name-value pair with the given name.
functionget constReturns the value of the first name-value pair with the given name. If no value with the given name has been found, the defaultValue is returned.
functionhas constReturns true if there is at least one name-value pair with the given name.
functionfind constReturns an iterator pointing to the first name-value pair with the given name.
functionbegin constReturns an iterator pointing to the begin of the name-value pair collection.
functionend constReturns an iterator pointing to the end of the name-value pair collection.
functionempty constReturns true iff the header does not have any content.
functionsize constReturns the number of name-value pairs in the collection.
functioneraseRemoves all name-value pairs with the given name.
functionclearRemoves all name-value pairs and their values.

Friends

NameDescription
operator<< inline

{#operator-18}

operator<<

inline

friend inline std::ostream & operator<<(std::ostream & stream, const Response & res)

Defined in src/http/include/icy/http/response.h:145

Public Methods

ReturnNameDescription
ResponseCreates the Response with OK status.
ResponseCreates the Response with the given status and reason phrase.
ResponseCreates the Response with the given version, status and reason phrase.
ResponseCreates the Response with the given status and an appropriate reason phrase.
ResponseCreates the Response with the given version, status and an appropriate reason phrase.
~Response virtualDestroys the Response.
voidsetStatusSets the HTTP status code.
StatusCodegetStatus const nodiscardReturns the HTTP status code.
voidsetReasonSets the HTTP reason phrase.
const std::string &getReason const nodiscardReturns the HTTP reason phrase.
voidsetStatusAndReasonSets the HTTP status code and reason phrase.
voidsetDateSets the Date header to the given date/time value.
TimestampgetDate const nodiscardReturns the value of the Date header.
voidaddCookieAdds the cookie to the response by adding a Set-Cookie header.
voidgetCookies constReturns a vector with all the cookies set in the response header.
voidwrite virtual constWrites the HTTP response headers to the given output stream.
voidwrite virtual constWrites the HTTP response headers to the given output string.
voidwrite virtual constWrites the HTTP response headers directly into a byte buffer.
boolsuccess virtual const nodiscardReturns true if the HTTP response code was successful (< 400).

{#response-2}

Response

Response()

Defined in src/http/include/icy/http/response.h:82

Creates the Response with OK status.


{#response-3}

Response

Response(StatusCode status, const std::string & reason)

Defined in src/http/include/icy/http/response.h:85

Creates the Response with the given status and reason phrase.


{#response-4}

Response

Response(const std::string & version, StatusCode status, const std::string & reason)

Defined in src/http/include/icy/http/response.h:88

Creates the Response with the given version, status and reason phrase.


{#response-5}

Response

Response(StatusCode status)

Defined in src/http/include/icy/http/response.h:92

Creates the Response with the given status and an appropriate reason phrase.


{#response-6}

Response

Response(const std::string & version, StatusCode status)

Defined in src/http/include/icy/http/response.h:96

Creates the Response with the given version, status and an appropriate reason phrase.


{#response-7}

~Response

virtual

virtual ~Response()

Defined in src/http/include/icy/http/response.h:99

Destroys the Response.


{#setstatus}

setStatus

void setStatus(StatusCode status)

Defined in src/http/include/icy/http/response.h:104

Sets the HTTP status code.

The reason phrase is set according to the status code.


{#getstatus}

getStatus

const nodiscard

[[nodiscard]] StatusCode getStatus() const

Defined in src/http/include/icy/http/response.h:107

Returns the HTTP status code.


{#setreason}

setReason

void setReason(const std::string & reason)

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

Sets the HTTP reason phrase.


{#getreason}

getReason

const nodiscard

[[nodiscard]] const std::string & getReason() const

Defined in src/http/include/icy/http/response.h:113

Returns the HTTP reason phrase.


{#setstatusandreason}

setStatusAndReason

void setStatusAndReason(StatusCode status, const std::string & reason)

Defined in src/http/include/icy/http/response.h:116

Sets the HTTP status code and reason phrase.


{#setdate}

setDate

void setDate(const Timestamp & dateTime)

Defined in src/http/include/icy/http/response.h:119

Sets the Date header to the given date/time value.


{#getdate}

getDate

const nodiscard

[[nodiscard]] Timestamp getDate() const

Defined in src/http/include/icy/http/response.h:122

Returns the value of the Date header.


{#addcookie}

addCookie

void addCookie(const Cookie & cookie)

Defined in src/http/include/icy/http/response.h:126

Adds the cookie to the response by adding a Set-Cookie header.


{#getcookies-1}

getCookies

const

void getCookies(std::vector< Cookie > & cookies) const

Defined in src/http/include/icy/http/response.h:131

Returns a vector with all the cookies set in the response header.

May throw an exception in case of a malformed Set-Cookie header.


{#write-12}

write

virtual const

virtual void write(std::ostream & ostr) const

Defined in src/http/include/icy/http/response.h:134

Writes the HTTP response headers to the given output stream.

Reimplements

{#write-13}

write

virtual const

virtual void write(std::string & str) const

Defined in src/http/include/icy/http/response.h:137

Writes the HTTP response headers to the given output string.

Reimplements

{#write-14}

write

virtual const

virtual void write(Buffer & buf) const

Defined in src/http/include/icy/http/response.h:140

Writes the HTTP response headers directly into a byte buffer.

Reimplements

{#success}

success

virtual const nodiscard

[[nodiscard]] virtual bool success() const

Defined in src/http/include/icy/http/response.h:143

Returns true if the HTTP response code was successful (< 400).

Private Attributes

ReturnNameDescription
StatusCode_status
std::string_reason

{#_status}

_status

StatusCode _status

Defined in src/http/include/icy/http/response.h:152


{#_reason}

_reason

std::string _reason

Defined in src/http/include/icy/http/response.h:153

{#server}

Server

#include <icy/http/server.h>
class Server

Defined in src/http/include/icy/http/server.h:332

Inherits: SocketAdapter

HTTP server implementation.

This HTTP server is not strictly standards compliant. It was created to be a fast (nocopy where possible) solution for streaming media to web browsers.

List of all members

NameKindOwner
ServerConnectionfriendDeclared here
ConnectionvariableDeclared here
ShutdownvariableDeclared here
ServerfunctionDeclared here
ServerfunctionDeclared here
ServerfunctionDeclared here
ServerfunctionDeclared here
startfunctionDeclared here
stopfunctionDeclared here
setReusePortfunctionDeclared here
setMaxPooledConnectionsfunctionDeclared here
setKeepAliveTimeoutfunctionDeclared here
connectionCountfunctionDeclared here
addressfunctionDeclared here
dateCachefunctionDeclared here
_loopvariableDeclared here
_addressvariableDeclared here
_socketvariableDeclared here
_timervariableDeclared here
_factoryvariableDeclared here
_connectionsvariableDeclared here
_poolvariableDeclared here
_dateCachevariableDeclared here
_keepAliveTimeoutvariableDeclared here
_reusePortvariableDeclared here
createResponderfunctionDeclared here
onClientSocketAcceptfunctionDeclared here
onConnectionReadyfunctionDeclared here
onConnectionClosefunctionDeclared here
onSocketClosefunctionDeclared here
onTimerfunctionDeclared here
loopfunctionDeclared here
priorityvariableInherited from SocketAdapter
SocketAdapterfunctionInherited from SocketAdapter
~SocketAdapterfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
setSenderfunctionInherited from SocketAdapter
senderfunctionInherited from SocketAdapter
addReceiverfunctionInherited from SocketAdapter
removeReceiverfunctionInherited from SocketAdapter
hasReceiverfunctionInherited from SocketAdapter
receiversfunctionInherited from SocketAdapter
onSocketConnectfunctionInherited from SocketAdapter
onSocketRecvfunctionInherited from SocketAdapter
onSocketErrorfunctionInherited from SocketAdapter
onSocketClosefunctionInherited from SocketAdapter
_sendervariableInherited from SocketAdapter
_receiversvariableInherited from SocketAdapter
_dirtyvariableInherited from SocketAdapter
cleanupReceiversfunctionInherited from SocketAdapter

Inherited from SocketAdapter

KindNameDescription
variablepriorityThe priority of this adapter for STL sort operations.
functionSocketAdapterCreates the SocketAdapter.
function~SocketAdapter virtual noexceptDestroys the SocketAdapter.
functionsend virtual nodiscardSends 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.
functionsend virtual nodiscard
functionsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
functionsendOwned virtual nodiscard
functionsendPacket virtualSends 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.
functionsendPacket virtual
functionsendPacket virtualSends 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.
functionsetSender virtualSets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
functionsenderReturns the output SocketAdapter pointer.
functionaddReceiver virtualSets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
functionremoveReceiver virtualRemove the given receiver.
functionhasReceiver virtualReturns true if the given receiver is connected.
functionreceiversReturns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
functiononSocketConnect virtualCalled 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.
functiononSocketRecv virtualCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtualCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtualCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
variable_sender
variable_receivers
variable_dirty
functioncleanupReceivers virtual

Friends

NameDescription
ServerConnection

{#serverconnection}

ServerConnection

friend class ServerConnection

Defined in src/http/include/icy/http/server.h:435

Public Attributes

ReturnNameDescription
LocalSignal< void(ServerConnection::Ptr)>ConnectionSignals when a new connection has been created. A reference to the new connection object is provided.
LocalSignal< void()>ShutdownSignals when the server is shutting down.

{#connection-8}

Connection

LocalSignal< void(ServerConnection::Ptr)> Connection

Defined in src/http/include/icy/http/server.h:406

Signals when a new connection has been created. A reference to the new connection object is provided.


{#shutdown-7}

Shutdown

LocalSignal< void()> Shutdown

Defined in src/http/include/icy/http/server.h:409

Signals when the server is shutting down.

Public Methods

ReturnNameDescription
ServerConstructs an HTTP server on the given host and port using an internally created TCP socket.
ServerConstructs an HTTP server on the given address using an internally created TCP socket.
ServerConstructs an HTTP server on the given host and port using a caller-supplied socket. Useful for HTTPS by passing an SSLSocket. The event loop is derived from the socket.
ServerConstructs an HTTP server on the given address using a caller-supplied socket. The event loop is derived from the socket.
voidstartStart the HTTP server.
voidstopStop the HTTP server.
voidsetReusePort inlineEnable SO_REUSEPORT for multicore server instances. Must be called before start(). Allows multiple server instances to bind the same address:port with kernel-level load balancing (Linux 3.9+).
voidsetMaxPooledConnections inlineSet the maximum number of pooled connections (default 128). Set to 0 to disable connection pooling entirely.
voidsetKeepAliveTimeout inlineSet the keep-alive idle timeout in seconds (default 30). Connections idle longer than this are closed by the timer. Set to 0 to disable idle timeout.
size_tconnectionCount const inline nodiscardReturn the number of active connections (all states).
net::Address &address nodiscardReturn the server bind address.
const DateCache &dateCache const inline nodiscardReturn the cached Date header for use in responses.

{#server-1}

Server

Server(const std::string & host, short port, uv::Loop * loop = uv::defaultLoop(), std::unique_ptr< ServerConnectionFactory > factory = std::make_unique< ServerConnectionFactory >())

Defined in src/http/include/icy/http/server.h:340

Constructs an HTTP server on the given host and port using an internally created TCP socket.

Parameters

  • host Bind address (e.g. "0.0.0.0" or "127.0.0.1").

  • port TCP port to listen on.

  • loop Event loop to use. Defaults to the default libuv loop.

  • factory Connection and responder factory. Defaults to the base factory.


{#server-2}

Server

Server(const net::Address & address, uv::Loop * loop = uv::defaultLoop(), std::unique_ptr< ServerConnectionFactory > factory = std::make_unique< ServerConnectionFactory >())

Defined in src/http/include/icy/http/server.h:348

Constructs an HTTP server on the given address using an internally created TCP socket.

Parameters

  • address Bind address and port.

  • loop Event loop to use. Defaults to the default libuv loop.

  • factory Connection and responder factory.


{#server-3}

Server

Server(const std::string & host, short port, net::TCPSocket::Ptr socket, std::unique_ptr< ServerConnectionFactory > factory = std::make_unique< ServerConnectionFactory >())

Defined in src/http/include/icy/http/server.h:358

Constructs an HTTP server on the given host and port using a caller-supplied socket. Useful for HTTPS by passing an SSLSocket. The event loop is derived from the socket.

Parameters

  • host Bind address.

  • port TCP port to listen on.

  • socket Pre-created socket (e.g. SSLSocket for HTTPS).

  • factory Connection and responder factory.


{#server-4}

Server

Server(const net::Address & address, net::TCPSocket::Ptr socket, std::unique_ptr< ServerConnectionFactory > factory = std::make_unique< ServerConnectionFactory >())

Defined in src/http/include/icy/http/server.h:367

Constructs an HTTP server on the given address using a caller-supplied socket. The event loop is derived from the socket.

Parameters

  • address Bind address and port.

  • socket Pre-created socket (e.g. SSLSocket for HTTPS).

  • factory Connection and responder factory.


{#start-11}

start

void start()

Defined in src/http/include/icy/http/server.h:374

Start the HTTP server.


{#stop-9}

stop

void stop()

Defined in src/http/include/icy/http/server.h:377

Stop the HTTP server.


{#setreuseport-1}

setReusePort

inline

inline void setReusePort(bool enable = true)

Defined in src/http/include/icy/http/server.h:384

Enable SO_REUSEPORT for multicore server instances. Must be called before start(). Allows multiple server instances to bind the same address:port with kernel-level load balancing (Linux 3.9+).


{#setmaxpooledconnections}

setMaxPooledConnections

inline

inline void setMaxPooledConnections(size_t n)

Defined in src/http/include/icy/http/server.h:388

Set the maximum number of pooled connections (default 128). Set to 0 to disable connection pooling entirely.


{#setkeepalivetimeout}

setKeepAliveTimeout

inline

inline void setKeepAliveTimeout(int seconds)

Defined in src/http/include/icy/http/server.h:393

Set the keep-alive idle timeout in seconds (default 30). Connections idle longer than this are closed by the timer. Set to 0 to disable idle timeout.


{#connectioncount}

connectionCount

const inline nodiscard

[[nodiscard]] inline size_t connectionCount() const

Defined in src/http/include/icy/http/server.h:396

Return the number of active connections (all states).


{#address-11}

address

nodiscard

[[nodiscard]] net::Address & address()

Defined in src/http/include/icy/http/server.h:399

Return the server bind address.


{#datecache-1}

dateCache

const inline nodiscard

[[nodiscard]] inline const DateCache & dateCache() const

Defined in src/http/include/icy/http/server.h:402

Return the cached Date header for use in responses.

Protected Attributes

ReturnNameDescription
uv::Loop *_loop
net::Address_address
net::TCPSocket::Ptr_socket
Timer_timer
std::unique_ptr< ServerConnectionFactory >_factory
std::unordered_map< ServerConnection *, ServerConnection::Ptr >_connections
ConnectionPool_pool
DateCache_dateCache
int_keepAliveTimeout
bool_reusePort

{#_loop-1}

_loop

uv::Loop * _loop

Defined in src/http/include/icy/http/server.h:424


{#_address}

_address

net::Address _address

Defined in src/http/include/icy/http/server.h:425


{#_socket-2}

_socket

net::TCPSocket::Ptr _socket

Defined in src/http/include/icy/http/server.h:426


{#_timer}

_timer

Timer _timer

Defined in src/http/include/icy/http/server.h:427


{#_factory}

_factory

std::unique_ptr< ServerConnectionFactory > _factory

Defined in src/http/include/icy/http/server.h:428


{#_connections-1}

_connections

std::unordered_map< ServerConnection *, ServerConnection::Ptr > _connections

Defined in src/http/include/icy/http/server.h:429


{#_pool-1}

_pool

ConnectionPool _pool

Defined in src/http/include/icy/http/server.h:430


{#_datecache}

_dateCache

DateCache _dateCache

Defined in src/http/include/icy/http/server.h:431


{#_keepalivetimeout}

_keepAliveTimeout

int _keepAliveTimeout {30}

Defined in src/http/include/icy/http/server.h:432


{#_reuseport}

_reusePort

bool _reusePort {false}

Defined in src/http/include/icy/http/server.h:433

Protected Methods

ReturnNameDescription
std::unique_ptr< ServerResponder >createResponder
voidonClientSocketAccept
voidonConnectionReady
voidonConnectionClose
boolonSocketClose virtualCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
voidonTimer
uv::Loop *loop const inline nodiscardReturn the event loop this server runs on.

{#createresponder}

createResponder

std::unique_ptr< ServerResponder > createResponder(ServerConnection & conn)

Defined in src/http/include/icy/http/server.h:412


{#onclientsocketaccept}

onClientSocketAccept

void onClientSocketAccept(const net::TCPSocket::Ptr & socket)

Defined in src/http/include/icy/http/server.h:414


{#onconnectionready}

onConnectionReady

void onConnectionReady(ServerConnection & conn)

Defined in src/http/include/icy/http/server.h:415


{#onconnectionclose-1}

onConnectionClose

void onConnectionClose(ServerConnection & conn)

Defined in src/http/include/icy/http/server.h:416


{#onsocketclose-3}

onSocketClose

virtual

virtual bool onSocketClose(net::Socket & socket)

Defined in src/http/include/icy/http/server.h:417

Called when the socket is closed. Forwards the event to all registered receivers in priority order.

Parameters

  • socket The socket that was closed.

Returns

true to stop propagation to subsequent receivers.

Reimplements

{#ontimer}

onTimer

void onTimer()

Defined in src/http/include/icy/http/server.h:418


{#loop-6}

loop

const inline nodiscard

[[nodiscard]] inline uv::Loop * loop() const

Defined in src/http/include/icy/http/server.h:421

Return the event loop this server runs on.

{#serverconnection-1}

ServerConnection

#include <icy/http/server.h>
class ServerConnection

Defined in src/http/include/icy/http/server.h:59

Inherits: Connection

HTTP server connection.

List of all members

NameKindOwner
PayloadvariableDeclared here
ClosevariableDeclared here
ServerConnectionfunctionDeclared here
serverfunctionDeclared here
statefunctionDeclared here
modefunctionDeclared here
upgradedfunctionDeclared here
streamingfunctionDeclared here
idleTimeoutEnabledfunctionDeclared here
reusableForPoolfunctionDeclared here
markActivefunctionDeclared here
resetfunctionDeclared here
touchfunctionDeclared here
idleSecondsfunctionDeclared here
beginStreamingfunctionDeclared here
endStreamingfunctionDeclared here
endStreamingfunctionDeclared here
sendHeaderfunctionDeclared here
closefunctionDeclared here
_servervariableDeclared here
_respondervariableDeclared here
_lastActivityvariableDeclared here
_statevariableDeclared here
_modevariableDeclared here
onHeadersfunctionDeclared here
onPayloadfunctionDeclared here
onCompletefunctionDeclared here
onClosefunctionDeclared here
incomingHeaderfunctionDeclared here
outgoingHeaderfunctionDeclared here
setStatefunctionDeclared here
requestHasBodyfunctionDeclared here
responseLooksStreamingfunctionDeclared here
PtrtypedefDeclared here
ConnectionStreamfriendInherited from Connection
ConnectionAdapterfriendInherited from Connection
ConnectionfunctionInherited from Connection
onHeadersfunctionInherited from Connection
onPayloadfunctionInherited from Connection
onCompletefunctionInherited from Connection
onClosefunctionInherited from Connection
sendfunctionInherited from Connection
sendOwnedfunctionInherited from Connection
sendHeaderfunctionInherited from Connection
closefunctionInherited from Connection
markActivefunctionInherited from Connection
beginStreamingfunctionInherited from Connection
endStreamingfunctionInherited from Connection
closedfunctionInherited from Connection
errorfunctionInherited from Connection
headerAutoSendEnabledfunctionInherited from Connection
setHeaderAutoSendEnabledfunctionInherited from Connection
replaceAdapterfunctionInherited from Connection
replaceAdapterfunctionInherited from Connection
securefunctionInherited from Connection
socketfunctionInherited from Connection
adapterfunctionInherited from Connection
requestfunctionInherited from Connection
responsefunctionInherited from Connection
incomingHeaderfunctionInherited from Connection
outgoingHeaderfunctionInherited from Connection
_socketvariableInherited from Connection
_adaptervariableInherited from Connection
_requestvariableInherited from Connection
_responsevariableInherited from Connection
_errorvariableInherited from Connection
_closedvariableInherited from Connection
_shouldSendHeadervariableInherited from Connection
setErrorfunctionInherited from Connection
onSocketConnectfunctionInherited from Connection
onSocketRecvfunctionInherited from Connection
onSocketErrorfunctionInherited from Connection
onSocketClosefunctionInherited from Connection
PtrtypedefInherited from Connection
priorityvariableInherited from SocketAdapter
SocketAdapterfunctionInherited from SocketAdapter
~SocketAdapterfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
setSenderfunctionInherited from SocketAdapter
senderfunctionInherited from SocketAdapter
addReceiverfunctionInherited from SocketAdapter
removeReceiverfunctionInherited from SocketAdapter
hasReceiverfunctionInherited from SocketAdapter
receiversfunctionInherited from SocketAdapter
onSocketConnectfunctionInherited from SocketAdapter
onSocketRecvfunctionInherited from SocketAdapter
onSocketErrorfunctionInherited from SocketAdapter
onSocketClosefunctionInherited from SocketAdapter
_sendervariableInherited from SocketAdapter
_receiversvariableInherited from SocketAdapter
_dirtyvariableInherited from SocketAdapter
cleanupReceiversfunctionInherited from SocketAdapter

Inherited from Connection

KindNameDescription
friendConnectionStream
friendConnectionAdapter
functionConnectionCreates a Connection using the given TCP socket.
functiononHeaders virtualCalled when the incoming HTTP headers have been fully parsed.
functiononPayload virtualCalled for each chunk of incoming body data after headers are complete.
functiononComplete virtualCalled when the incoming HTTP message is fully received.
functiononClose virtualCalled when the connection is closed.
functionsend virtual overrideSend raw data to the peer.
functionsendOwned virtual overrideSend an owned payload buffer to the peer.
functionsendHeader virtualSend the outdoing HTTP header.
functionclose virtualClose the connection and schedule the object for deferred deletion.
functionmarkActive virtual inlineMarks the connection as active. Server connections override this to refresh the idle timer.
functionbeginStreaming virtual inlineExplicitly 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.
functionendStreaming virtual inlineExit long-lived streaming mode.
functionclosed const nodiscardReturn true if the connection is closed.
functionerror const nodiscardReturn the error object if any.
functionheaderAutoSendEnabled const nodiscardReturn true if headers should be automatically sent.
functionsetHeaderAutoSendEnabledEnable or disable automatic header emission for the next outgoing send path.
functionreplaceAdapter virtualAssign the new ConnectionAdapter and setup the chain. The flow is: Connection <-> ConnectionAdapter <-> Socket. Takes ownership of the adapter (deferred deletion via uv loop).
functionreplaceAdapter virtualOverload for nullptr (used in destructor to clear adapter).
functionsecure const nodiscardReturn true if the connection uses TLS/SSL.
functionsocket nodiscardReturn the underlying socket pointer.
functionadapter const nodiscardReturn the underlying adapter pointer.
functionrequest nodiscardThe HTTP request headers.
functionresponse nodiscardThe HTTP response headers.
functionincomingHeader virtualReturns the incoming HTTP message header (request or response depending on role).
functionoutgoingHeader virtualReturns 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
functionsetError virtualSet the internal error. Note: Setting the error does not [close()](#close-20) the connection.
functiononSocketConnect virtual overridenet::SocketAdapter interface
functiononSocketRecv virtual overrideCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtual overrideCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtual overrideCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
typedefPtr

Inherited from SocketAdapter

KindNameDescription
variablepriorityThe priority of this adapter for STL sort operations.
functionSocketAdapterCreates the SocketAdapter.
function~SocketAdapter virtual noexceptDestroys the SocketAdapter.
functionsend virtual nodiscardSends 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.
functionsend virtual nodiscard
functionsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
functionsendOwned virtual nodiscard
functionsendPacket virtualSends 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.
functionsendPacket virtual
functionsendPacket virtualSends 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.
functionsetSender virtualSets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
functionsenderReturns the output SocketAdapter pointer.
functionaddReceiver virtualSets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
functionremoveReceiver virtualRemove the given receiver.
functionhasReceiver virtualReturns true if the given receiver is connected.
functionreceiversReturns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
functiononSocketConnect virtualCalled 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.
functiononSocketRecv virtualCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtualCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtualCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
variable_sender
variable_receivers
variable_dirty
functioncleanupReceivers virtual

Public Attributes

ReturnNameDescription
LocalSignal< void(ServerConnection &, const MutableBuffer &)>PayloadSignals when raw data is received.
LocalSignal< void(ServerConnection &)>CloseSignals when the connection is closed.

{#payload-1}

Payload

LocalSignal< void(ServerConnection &, const MutableBuffer &)> Payload

Defined in src/http/include/icy/http/server.h:118

Signals when raw data is received.


{#close-21}

Close

LocalSignal< void(ServerConnection &)> Close

Defined in src/http/include/icy/http/server.h:119

Signals when the connection is closed.

Public Methods

ReturnNameDescription
ServerConnectionCreates a ServerConnection attached to the given server and socket.
Server &server nodiscardReturns the owning Server instance.
ServerConnectionStatestate const inline nodiscardReturns the current server-side connection state.
ServerConnectionModemode const inline nodiscardReturns the current transport mode.
boolupgraded const inline nodiscardReturns true if the connection has been upgraded (e.g. to WebSocket).
boolstreaming const inline nodiscardReturns true if the connection is in long-lived streaming mode.
boolidleTimeoutEnabled const nodiscardReturns true if the server idle timer is allowed to reap this connection.
boolreusableForPool const nodiscardReturns true if the closed connection can be returned to the reuse pool.
voidmarkActive virtual inline overrideRefresh the idle timer.
voidresetReset this connection for reuse with a new socket. Called by the connection pool to avoid allocating a new ServerConnection.
voidtouch inlineUpdate the last activity timestamp.
doubleidleSeconds const inline nodiscardReturn seconds since last activity.
voidbeginStreaming virtual overrideExplicitly mark the response as long-lived streaming. Streaming connections are excluded from the keep-alive idle reaper.
voidendStreaming virtual overrideExit streaming mode and return to the given HTTP state.
voidendStreaming
ssize_tsendHeader virtual overrideSend the outgoing HTTP header.
voidclose virtual overrideClose the connection with an explicit terminal state transition.

{#serverconnection-2}

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

  • server The owning HTTP server instance.

  • socket The accepted TCP socket for this connection.


{#server-5}

server

nodiscard

[[nodiscard]] Server & server()

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

Returns the owning Server instance.


{#state-1}

state

const inline nodiscard

[[nodiscard]] inline ServerConnectionState state() const

Defined in src/http/include/icy/http/server.h:74

Returns the current server-side connection state.


{#mode-1}

mode

const inline nodiscard

[[nodiscard]] inline ServerConnectionMode mode() const

Defined in src/http/include/icy/http/server.h:77

Returns the current transport mode.


{#upgraded}

upgraded

const inline nodiscard

[[nodiscard]] inline bool upgraded() const

Defined in src/http/include/icy/http/server.h:80

Returns true if the connection has been upgraded (e.g. to WebSocket).


{#streaming}

streaming

const inline nodiscard

[[nodiscard]] inline bool streaming() const

Defined in src/http/include/icy/http/server.h:83

Returns true if the connection is in long-lived streaming mode.


{#idletimeoutenabled}

idleTimeoutEnabled

const nodiscard

[[nodiscard]] bool idleTimeoutEnabled() const

Defined in src/http/include/icy/http/server.h:86

Returns true if the server idle timer is allowed to reap this connection.


{#reusableforpool}

reusableForPool

const nodiscard

[[nodiscard]] bool reusableForPool() const

Defined in src/http/include/icy/http/server.h:89

Returns true if the closed connection can be returned to the reuse pool.


{#markactive-1}

markActive

virtual inline override

virtual inline void markActive() override

Defined in src/http/include/icy/http/server.h:92

Refresh the idle timer.

Reimplements

{#reset-12}

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}

touch

inline

inline void touch()

Defined in src/http/include/icy/http/server.h:99

Update the last activity timestamp.


{#idleseconds}

idleSeconds

const inline nodiscard

[[nodiscard]] inline double idleSeconds() const

Defined in src/http/include/icy/http/server.h:102

Return seconds since last activity.


{#beginstreaming-1}

beginStreaming

virtual override

virtual void beginStreaming() override

Defined 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-1}

endStreaming

virtual override

virtual void endStreaming() override

Defined in src/http/include/icy/http/server.h:109

Exit streaming mode and return to the given HTTP state.

Reimplements

{#endstreaming-2}

endStreaming

void endStreaming(ServerConnectionState nextState)

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


{#sendheader-1}

sendHeader

virtual override

virtual ssize_t sendHeader() override

Defined in src/http/include/icy/http/server.h:113

Send the outgoing HTTP header.

Reimplements

{#close-22}

close

virtual override

virtual void close() override

Defined in src/http/include/icy/http/server.h:116

Close the connection with an explicit terminal state transition.

Reimplements

Protected Attributes

ReturnNameDescription
Server &_server
std::unique_ptr< ServerResponder >_responder
std::time_t_lastActivity
ServerConnectionState_state
ServerConnectionMode_mode

{#_server}

_server

Server & _server

Defined in src/http/include/icy/http/server.h:135


{#_responder}

_responder

std::unique_ptr< ServerResponder > _responder

Defined in src/http/include/icy/http/server.h:136


{#_lastactivity}

_lastActivity

std::time_t _lastActivity {0}

Defined in src/http/include/icy/http/server.h:137


{#_state-2}

_state

ServerConnectionState _state {}

Defined in src/http/include/icy/http/server.h:138


{#_mode-2}

_mode

ServerConnectionMode _mode {}

Defined in src/http/include/icy/http/server.h:139

Protected Methods

ReturnNameDescription
voidonHeaders virtual overrideCalled when the incoming HTTP headers have been fully parsed.
voidonPayload virtual overrideCalled for each chunk of incoming body data after headers are complete.
voidonComplete virtual overrideCalled when the incoming HTTP message is fully received.
voidonClose virtual overrideCalled when the connection is closed.
http::Message *incomingHeader virtual overrideReturns the incoming HTTP message header (request or response depending on role).
http::Message *outgoingHeader virtual overrideReturns the outgoing HTTP message header (request or response depending on role).
voidsetState
boolrequestHasBody const nodiscard
boolresponseLooksStreaming const nodiscard

{#onheaders-2}

onHeaders

virtual override

virtual void onHeaders() override

Defined in src/http/include/icy/http/server.h:122

Called when the incoming HTTP headers have been fully parsed.

Reimplements

{#onpayload-2}

onPayload

virtual override

virtual void onPayload(const MutableBuffer & buffer) override

Defined in src/http/include/icy/http/server.h:123

Called for each chunk of incoming body data after headers are complete.

Parameters

  • buffer Buffer containing the received data chunk.
Reimplements

{#oncomplete-2}

onComplete

virtual override

virtual void onComplete() override

Defined in src/http/include/icy/http/server.h:124

Called when the incoming HTTP message is fully received.

Reimplements

{#onclose-5}

onClose

virtual override

virtual void onClose() override

Defined in src/http/include/icy/http/server.h:125

Called when the connection is closed.

Reimplements

{#incomingheader-2}

incomingHeader

virtual override

virtual http::Message * incomingHeader() override

Defined in src/http/include/icy/http/server.h:127

Returns the incoming HTTP message header (request or response depending on role).

Reimplements

{#outgoingheader-2}

outgoingHeader

virtual override

virtual http::Message * outgoingHeader() override

Defined in src/http/include/icy/http/server.h:128

Returns the outgoing HTTP message header (request or response depending on role).

Reimplements

{#setstate}

setState

void setState(ServerConnectionState state)

Defined in src/http/include/icy/http/server.h:130


{#requesthasbody}

requestHasBody

const nodiscard

[[nodiscard]] bool requestHasBody() const

Defined in src/http/include/icy/http/server.h:131


{#responselooksstreaming}

responseLooksStreaming

const nodiscard

[[nodiscard]] bool responseLooksStreaming() const

Defined in src/http/include/icy/http/server.h:132

Public Types

NameDescription
Ptr

{#ptr-13}

Ptr

using Ptr = std::shared_ptr< ServerConnection >

Defined in src/http/include/icy/http/server.h:62

{#serverconnectionfactory}

ServerConnectionFactory

#include <icy/http/server.h>
class ServerConnectionFactory

Defined in src/http/include/icy/http/server.h:206

Factory for creating per-socket [ServerConnection](#serverconnection-1) and per-request [ServerResponder](#serverresponder) objects.

List of all members

NameKindOwner
ServerConnectionFactoryfunctionDeclared here
createConnectionfunctionDeclared here
createResponderfunctionDeclared here

Public Methods

ReturnNameDescription
ServerConnectionFactoryDefaulted constructor.
ServerConnection::PtrcreateConnection virtual inlineCreates the [ServerConnection](#serverconnection-1) wrapper for an accepted TCP socket.
std::unique_ptr< ServerResponder >createResponder virtual inlineCreates the responder for the current request on connection.

{#serverconnectionfactory-1}

ServerConnectionFactory

ServerConnectionFactory() = default

Defined in src/http/include/icy/http/server.h:209

Defaulted constructor.


{#createconnection-2}

createConnection

virtual inline

virtual inline ServerConnection::Ptr createConnection(Server & server, const net::TCPSocket::Ptr & socket)

Defined in src/http/include/icy/http/server.h:213

Creates the [ServerConnection](#serverconnection-1) wrapper for an accepted TCP socket.


{#createresponder-1}

createResponder

virtual inline

virtual inline std::unique_ptr< ServerResponder > createResponder(ServerConnection & connection)

Defined in src/http/include/icy/http/server.h:219

Creates the responder for the current request on connection.

{#serverresponder}

ServerResponder

#include <icy/http/server.h>
class ServerResponder

Defined in src/http/include/icy/http/server.h:145

Base responder interface for handling one HTTP request on a server connection. Derived classes typically override [onRequest()](#onrequest) and optionally the streaming hooks.

List of all members

NameKindOwner
ServerResponderfunctionDeclared here
onHeadersfunctionDeclared here
onPayloadfunctionDeclared here
onRequestfunctionDeclared here
onClosefunctionDeclared here
connectionfunctionDeclared here
requestfunctionDeclared here
responsefunctionDeclared here
_connectionvariableDeclared here
ServerResponderfunctionDeclared here

Public Methods

ReturnNameDescription
ServerResponder inlineCreates a ServerResponder for the given connection.
voidonHeaders virtual inlineCalled when the incoming request headers have been parsed.
voidonPayload virtual inlineCalled for each chunk of incoming request body data.
voidonRequest virtual inlineCalled when the complete HTTP request has been received. Derived classes should write their response here.
voidonClose virtual inlineCalled when the connection is closed.
ServerConnection &connection inline nodiscardReturns the underlying server connection.
Request &request inline nodiscardReturns the current HTTP request from the underlying connection.
Response &response inline nodiscardReturns the current HTTP response from the underlying connection.

{#serverresponder-1}

ServerResponder

inline

inline ServerResponder(ServerConnection & connection)

Defined in src/http/include/icy/http/server.h:150

Creates a ServerResponder for the given connection.

Parameters

  • connection The server connection this responder handles.

{#onheaders-3}

onHeaders

virtual inline

virtual inline void onHeaders(Request & request)

Defined in src/http/include/icy/http/server.h:159

Called when the incoming request headers have been parsed.

Parameters

  • request The parsed HTTP request with headers populated.

{#onpayload-3}

onPayload

virtual inline

virtual inline void onPayload(const MutableBuffer & body)

Defined in src/http/include/icy/http/server.h:163

Called for each chunk of incoming request body data.

Parameters

  • body Buffer containing a chunk of the request body.

{#onrequest}

onRequest

virtual inline

virtual inline void onRequest(Request & request, Response & response)

Defined in src/http/include/icy/http/server.h:169

Called when the complete HTTP request has been received. Derived classes should write their response here.

Parameters

  • request The fully received HTTP request.

  • response The HTTP response to populate and send.


{#onclose-6}

onClose

virtual inline

virtual inline void onClose()

Defined in src/http/include/icy/http/server.h:176

Called when the connection is closed.


{#connection-9}

connection

inline nodiscard

[[nodiscard]] inline ServerConnection & connection()

Defined in src/http/include/icy/http/server.h:179

Returns the underlying server connection.


{#request-10}

request

inline nodiscard

[[nodiscard]] inline Request & request()

Defined in src/http/include/icy/http/server.h:185

Returns the current HTTP request from the underlying connection.


{#response-8}

response

inline nodiscard

[[nodiscard]] inline Response & response()

Defined in src/http/include/icy/http/server.h:191

Returns the current HTTP response from the underlying connection.

Protected Attributes

ReturnNameDescription
ServerConnection &_connection

{#_connection-2}

_connection

ServerConnection & _connection

Defined in src/http/include/icy/http/server.h:197

Private Methods

ReturnNameDescription
ServerResponderDeleted constructor.

{#serverresponder-2}

ServerResponder

ServerResponder(const ServerResponder &) = delete

Defined in src/http/include/icy/http/server.h:200

Deleted constructor.

{#stringpart-1}

StringPart

#include <icy/http/form.h>
class StringPart

Defined in src/http/include/icy/http/form.h:306

Inherits: FormPart

Form part backed by an in-memory string payload.

List of all members

NameKindOwner
StringPartfunctionDeclared here
StringPartfunctionDeclared here
~StringPartfunctionDeclared here
writeChunkfunctionDeclared here
writefunctionDeclared here
writefunctionDeclared here
lengthfunctionDeclared here
_datavariableDeclared here
FormPartfunctionInherited from FormPart
~FormPartfunctionInherited from FormPart
resetfunctionInherited from FormPart
writeChunkfunctionInherited from FormPart
writefunctionInherited from FormPart
writefunctionInherited from FormPart
headersfunctionInherited from FormPart
initialWritefunctionInherited from FormPart
contentTypefunctionInherited from FormPart
lengthfunctionInherited from FormPart
_contentTypevariableInherited from FormPart
_lengthvariableInherited from FormPart
_headersvariableInherited from FormPart
_initialWritevariableInherited from FormPart

Inherited from FormPart

KindNameDescription
functionFormPartCreates the FormPart with the given MIME content type.
function~FormPart virtualDestroys the FormPart.
functionreset virtualResets the internal state and write position to the beginning. Called by FormWriter when retrying or recalculating content length.
functionwriteChunk virtualWrites the next chunk of data to the FormWriter.
functionwrite virtualWrites the entire part data to the FormWriter in one call.
functionwrite virtualWrites the entire part data to an output stream (used for content-length calculation).
functionheaders nodiscardReturns the extra MIME headers for this part (e.g. Content-Disposition).
functioninitialWrite virtual const nodiscardReturns true if this is the first write call since construction or reset().
functioncontentType const nodiscardReturns the MIME content type for this part.
functionlength virtual const nodiscardReturns the total byte length of the part data.
variable_contentType
variable_length
variable_headers
variable_initialWrite

Public Methods

ReturnNameDescription
StringPartCreates a StringPart with the given data and default content type "application/octet-stream".
StringPartCreates a StringPart with the given data and MIME content type.
~StringPart virtualDestroys the StringPart.
boolwriteChunk virtual overrideWrites the string data as a single chunk to the FormWriter.
voidwrite virtual overrideWrites the string data to the FormWriter.
voidwrite virtual overrideWrites the string data to an output stream.
uint64_tlength virtual const nodiscard overrideReturns the byte length of the string data.

{#stringpart-2}

StringPart

StringPart(const std::string & data)

Defined in src/http/include/icy/http/form.h:311

Creates a StringPart with the given data and default content type "application/octet-stream".

Parameters

  • data String data to send as this part.

{#stringpart-3}

StringPart

StringPart(const std::string & data, const std::string & contentType)

Defined in src/http/include/icy/http/form.h:316

Creates a StringPart with the given data and MIME content type.

Parameters

  • data String data to send as this part.

  • contentType MIME type for this part.


{#stringpart-4}

~StringPart

virtual

virtual ~StringPart()

Defined in src/http/include/icy/http/form.h:319

Destroys the StringPart.


{#writechunk-2}

writeChunk

virtual override

virtual bool writeChunk(FormWriter & writer) override

Defined in src/http/include/icy/http/form.h:324

Writes the string data as a single chunk to the FormWriter.

Parameters

Returns

false always (string data is sent in a single chunk).

Reimplements

{#write-15}

write

virtual override

virtual void write(FormWriter & writer) override

Defined in src/http/include/icy/http/form.h:328

Writes the string data to the FormWriter.

Parameters

Reimplements

{#write-16}

write

virtual override

virtual void write(std::ostream & ostr) override

Defined in src/http/include/icy/http/form.h:332

Writes the string data to an output stream.

Parameters

  • ostr Output stream to write to.
Reimplements

{#length-3}

length

virtual const nodiscard override

[[nodiscard]] virtual uint64_t length() const override

Defined in src/http/include/icy/http/form.h:335

Returns the byte length of the string data.

Reimplements

Protected Attributes

ReturnNameDescription
std::string_data

{#_data}

_data

std::string _data

Defined in src/http/include/icy/http/form.h:338

{#url}

URL

#include <icy/http/url.h>
class URL

Defined in src/http/include/icy/http/url.h:28

An RFC 3986 based URL parser. Constructors and assignment operators will throw a SyntaxException if the URL is invalid.

List of all members

NameKindOwner
operator<<friendDeclared here
URLfunctionDeclared here
URLfunctionDeclared here
URLfunctionDeclared here
URLfunctionDeclared here
URLfunctionDeclared here
URLfunctionDeclared here
URLfunctionDeclared here
operator=functionDeclared here
operator=functionDeclared here
operator=functionDeclared here
parsefunctionDeclared here
schemefunctionDeclared here
userInfofunctionDeclared here
hostfunctionDeclared here
portfunctionDeclared here
authorityfunctionDeclared here
pathfunctionDeclared here
pathEtcfunctionDeclared here
queryfunctionDeclared here
fragmentfunctionDeclared here
hasSchemafunctionDeclared here
hasUserInfofunctionDeclared here
hasHostfunctionDeclared here
hasPortfunctionDeclared here
hasPathfunctionDeclared here
hasQueryfunctionDeclared here
hasFragmentfunctionDeclared here
validfunctionDeclared here
strfunctionDeclared here
encodefunctionDeclared here
decodefunctionDeclared here
_bufvariableDeclared here
_schemevariableDeclared here
_userInfovariableDeclared here
_hostvariableDeclared here
_portvariableDeclared here
_pathvariableDeclared here
_queryvariableDeclared here
_fragmentvariableDeclared here
_hasPortvariableDeclared here

Friends

NameDescription
operator<< inline

{#operator-19}

operator<<

inline

friend inline std::ostream & operator<<(std::ostream & stream, const URL & url)

Defined in src/http/include/icy/http/url.h:163

Public Methods

ReturnNameDescription
URLCreates an empty URL.
URLParses the URL from a null-terminated string.
URLParses the URL from a std::string.
URLConstructs a URL from scheme and authority components.
URLConstructs a URL from scheme, authority, and path+query+fragment.
URLConstructs a URL from individual components.
URLDefaulted constructor.
URL &operator=Assigns a URL from another URL instance.
URL &operator=Assigns a URL from a null-terminated string.
URL &operator=Assigns a URL from a std::string.
boolparseParses and assigns a URL from the given string view, resetting all components first.
std::stringscheme const nodiscardReturns the URL scheme (e.g. "http", "https", "ws"). Always lowercase.
std::stringuserInfo const nodiscardReturns the user info component (e.g. "user:pass" from "http://user:pass@host/"). Returns an empty string if not present.
std::stringhost const nodiscardReturns the host component (e.g. "example.com"). Returns an empty string if not present.
uint16_tport const nodiscardReturns the port number. If no explicit port was in the URL, returns the default port for the scheme (80 for http, 443 for https), or 0 if the scheme is unknown.
std::stringauthority const nodiscardReturns the authority component (userinfo@[host](#host-1):[port](#port-1)). Only includes components that are present.
std::stringpath const nodiscardReturns the path component (e.g. "/index.html"). Returns an empty string if not present.
std::stringpathEtc const nodiscardReturns the path, query and fragment combined (e.g. "/path?q=1#frag").
std::stringquery const nodiscardReturns the query string without the leading '?' (e.g. "key=value&foo=bar"). Returns an empty string if not present.
std::stringfragment const nodiscardReturns the fragment identifier without the leading '#'. Returns an empty string if not present.
boolhasSchema const nodiscardReturns true if the URL has a scheme component.
boolhasUserInfo const nodiscardReturns true if the URL has a user info component.
boolhasHost const nodiscardReturns true if the URL has a host component.
boolhasPort const nodiscardReturns true if an explicit port was specified in the URL.
boolhasPath const nodiscardReturns true if the URL has a path component.
boolhasQuery const nodiscardReturns true if the URL has a query component.
boolhasFragment const nodiscardReturns true if the URL has a fragment component.
boolvalid const nodiscardReturns true if the URL is non-empty and was successfully parsed.
std::stringstr const nodiscardReturns the original URL string as parsed.

{#url-1}

URL

URL()

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

Creates an empty URL.


{#url-2}

URL

URL(const char * url)

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

Parses the URL from a null-terminated string.

Parameters

  • url Null-terminated URL string to parse.

{#url-3}

URL

URL(const std::string & url)

Defined in src/http/include/icy/http/url.h:40

Parses the URL from a std::string.

Parameters

  • url URL string to parse.

{#url-4}

URL

URL(const std::string & scheme, const std::string & authority)

Defined in src/http/include/icy/http/url.h:45

Constructs a URL from scheme and authority components.

Parameters

  • scheme URL scheme (e.g. "http", "https").

  • authority Host and optional port (e.g. "example.com:8080").


{#url-5}

URL

URL(const std::string & scheme, const std::string & authority, const std::string & pathEtc)

Defined in src/http/include/icy/http/url.h:51

Constructs a URL from scheme, authority, and path+query+fragment.

Parameters

  • scheme URL scheme (e.g. "http").

  • authority Host and optional port.

  • pathEtc Path, query and fragment combined (e.g. "/path?q=1#frag").


{#url-6}

URL

URL(const std::string & scheme, const std::string & authority, const std::string & path, const std::string & query, const std::string & fragment = "")

Defined in src/http/include/icy/http/url.h:60

Constructs a URL from individual components.

Parameters

  • scheme URL scheme (e.g. "http").

  • authority Host and optional port.

  • path URL path (e.g. "/index.html").

  • query Query string without leading '?' (e.g. "key=value").

  • fragment Fragment identifier without leading '#'.


{#url-7}

URL

URL(const URL &) = default

Defined in src/http/include/icy/http/url.h:64

Defaulted constructor.


{#operator-20}

operator=

URL & operator=(const URL & uri)

Defined in src/http/include/icy/http/url.h:70

Assigns a URL from another URL instance.

Parameters

  • uri Source URL to copy from.

Returns

Reference to this URL.


{#operator-21}

operator=

URL & operator=(const char * uri)

Defined in src/http/include/icy/http/url.h:75

Assigns a URL from a null-terminated string.

Parameters

  • uri Null-terminated URL string to parse.

Returns

Reference to this URL.


{#operator-22}

operator=

URL & operator=(const std::string & uri)

Defined in src/http/include/icy/http/url.h:80

Assigns a URL from a std::string.

Parameters

  • uri URL string to parse.

Returns

Reference to this URL.


{#parse-1}

parse

bool parse(std::string_view url, bool whiny = true)

Defined in src/http/include/icy/http/url.h:86

Parses and assigns a URL from the given string view, resetting all components first.

Parameters

  • url URL string to parse.

  • whiny If true, throws std::runtime_error on an invalid URL; otherwise returns false.

Returns

true if the URL was parsed successfully; false if invalid and whiny is false.


{#scheme}

scheme

const nodiscard

[[nodiscard]] std::string scheme() const

Defined in src/http/include/icy/http/url.h:102

Returns the URL scheme (e.g. "http", "https", "ws"). Always lowercase.


{#userinfo}

userInfo

const nodiscard

[[nodiscard]] std::string userInfo() const

Defined in src/http/include/icy/http/url.h:106

Returns the user info component (e.g. "user:pass" from "http://user:pass@host/"). Returns an empty string if not present.


{#host-1}

host

const nodiscard

[[nodiscard]] std::string host() const

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

Returns the host component (e.g. "example.com"). Returns an empty string if not present.


{#port-1}

port

const nodiscard

[[nodiscard]] uint16_t port() const

Defined in src/http/include/icy/http/url.h:115

Returns the port number. If no explicit port was in the URL, returns the default port for the scheme (80 for http, 443 for https), or 0 if the scheme is unknown.


{#authority}

authority

const nodiscard

[[nodiscard]] std::string authority() const

Defined in src/http/include/icy/http/url.h:119

Returns the authority component (userinfo@[host](#host-1):[port](#port-1)). Only includes components that are present.


{#path}

path

const nodiscard

[[nodiscard]] std::string path() const

Defined in src/http/include/icy/http/url.h:123

Returns the path component (e.g. "/index.html"). Returns an empty string if not present.


{#pathetc}

pathEtc

const nodiscard

[[nodiscard]] std::string pathEtc() const

Defined in src/http/include/icy/http/url.h:126

Returns the path, query and fragment combined (e.g. "/path?q=1#frag").


{#query}

query

const nodiscard

[[nodiscard]] std::string query() const

Defined in src/http/include/icy/http/url.h:130

Returns the query string without the leading '?' (e.g. "key=value&foo=bar"). Returns an empty string if not present.


{#fragment}

fragment

const nodiscard

[[nodiscard]] std::string fragment() const

Defined in src/http/include/icy/http/url.h:134

Returns the fragment identifier without the leading '#'. Returns an empty string if not present.


{#hasschema}

hasSchema

const nodiscard

[[nodiscard]] bool hasSchema() const

Defined in src/http/include/icy/http/url.h:137

Returns true if the URL has a scheme component.


{#hasuserinfo}

hasUserInfo

const nodiscard

[[nodiscard]] bool hasUserInfo() const

Defined in src/http/include/icy/http/url.h:140

Returns true if the URL has a user info component.


{#hashost}

hasHost

const nodiscard

[[nodiscard]] bool hasHost() const

Defined in src/http/include/icy/http/url.h:143

Returns true if the URL has a host component.


{#hasport}

hasPort

const nodiscard

[[nodiscard]] bool hasPort() const

Defined in src/http/include/icy/http/url.h:146

Returns true if an explicit port was specified in the URL.


{#haspath}

hasPath

const nodiscard

[[nodiscard]] bool hasPath() const

Defined in src/http/include/icy/http/url.h:149

Returns true if the URL has a path component.


{#hasquery}

hasQuery

const nodiscard

[[nodiscard]] bool hasQuery() const

Defined in src/http/include/icy/http/url.h:152

Returns true if the URL has a query component.


{#hasfragment}

hasFragment

const nodiscard

[[nodiscard]] bool hasFragment() const

Defined in src/http/include/icy/http/url.h:155

Returns true if the URL has a fragment component.


{#valid-1}

valid

const nodiscard

[[nodiscard]] bool valid() const

Defined in src/http/include/icy/http/url.h:158

Returns true if the URL is non-empty and was successfully parsed.


{#str-1}

str

const nodiscard

[[nodiscard]] std::string str() const

Defined in src/http/include/icy/http/url.h:161

Returns the original URL string as parsed.

Public Static Methods

ReturnNameDescription
std::stringencode staticPercent-encodes a string per RFC 3986, preserving unreserved characters (A-Z, a-z, 0-9, '-', '_', '.', '~'). Equivalent to JavaScript's encodeURIComponent().
std::stringdecode staticDecodes a percent-encoded string per RFC 3986. Equivalent to JavaScript's decodeURIComponent().

{#encode-21}

encode

static

static std::string encode(std::string_view str)

Defined in src/http/include/icy/http/url.h:92

Percent-encodes a string per RFC 3986, preserving unreserved characters (A-Z, a-z, 0-9, '-', '_', '.', '~'). Equivalent to JavaScript's encodeURIComponent().

Parameters

  • str Input string to encode.

Returns

Percent-encoded string.


{#decode-10}

decode

static

static std::string decode(std::string_view str)

Defined in src/http/include/icy/http/url.h:98

Decodes a percent-encoded string per RFC 3986. Equivalent to JavaScript's decodeURIComponent().

Parameters

  • str Percent-encoded input string.

Returns

Decoded string.

Protected Attributes

ReturnNameDescription
std::string_buf
std::string_scheme
std::string_userInfo
std::string_host
uint16_t_port
std::string_path
std::string_query
std::string_fragment
bool_hasPort

{#_buf}

_buf

std::string _buf

Defined in src/http/include/icy/http/url.h:170


{#_scheme}

_scheme

std::string _scheme

Defined in src/http/include/icy/http/url.h:171


{#_userinfo}

_userInfo

std::string _userInfo

Defined in src/http/include/icy/http/url.h:172


{#_host}

_host

std::string _host

Defined in src/http/include/icy/http/url.h:173


{#_port}

_port

uint16_t _port

Defined in src/http/include/icy/http/url.h:174


{#_path-2}

_path

std::string _path

Defined in src/http/include/icy/http/url.h:175


{#_query}

_query

std::string _query

Defined in src/http/include/icy/http/url.h:176


{#_fragment}

_fragment

std::string _fragment

Defined in src/http/include/icy/http/url.h:177


{#_hasport}

_hasPort

bool _hasPort

Defined in src/http/include/icy/http/url.h:178

{#datecache}

DateCache

#include <icy/http/server.h>
struct DateCache

Defined in src/http/include/icy/http/server.h:228

Caches the formatted Date header, updated once per second. Avoids per-request time formatting and string allocation.

List of all members

NameKindOwner
bufvariableDeclared here
lenvariableDeclared here
lastSecondvariableDeclared here
updatefunctionDeclared here
datafunctionDeclared here
sizefunctionDeclared here

Public Attributes

ReturnNameDescription
charbuf
size_tlen
std::time_tlastSecond

{#buf}

buf

char buf {}

Defined in src/http/include/icy/http/server.h:230


{#len}

len

size_t len = 0

Defined in src/http/include/icy/http/server.h:231


{#lastsecond}

lastSecond

std::time_t lastSecond = 0

Defined in src/http/include/icy/http/server.h:232

Public Methods

ReturnNameDescription
voidupdate inlineRefreshes the cached Date header string if the current second has changed. No-op if called multiple times within the same second.
const char *data const inline nodiscardReturns a pointer to the formatted "Date: ...\r\n" header string.
size_tsize const inline nodiscardReturns the byte length of the formatted Date header string.

{#update}

update

inline

inline void update()

Defined in src/http/include/icy/http/server.h:236

Refreshes the cached Date header string if the current second has changed. No-op if called multiple times within the same second.


{#data-2}

data

const inline nodiscard

[[nodiscard]] inline const char * data() const

Defined in src/http/include/icy/http/server.h:253

Returns a pointer to the formatted "Date: ...\r\n" header string.


{#size-1}

size

const inline nodiscard

[[nodiscard]] inline size_t size() const

Defined in src/http/include/icy/http/server.h:256

Returns the byte length of the formatted Date header string.

{#method}

Method

#include <icy/http/request.h>
struct Method

Defined in src/http/include/icy/http/request.h:26

HTTP request methods.

List of all members

NameKindOwner
GetvariableDeclared here
HeadvariableDeclared here
PutvariableDeclared here
PostvariableDeclared here
OptionsvariableDeclared here
DeletevariableDeclared here
TracevariableDeclared here
ConnectvariableDeclared here

Public Static Attributes

ReturnNameDescription
const std::stringGet static
const std::stringHead static
const std::stringPut static
const std::stringPost static
const std::stringOptions static
const std::stringDelete static
const std::stringTrace static
const std::stringConnect static

{#get-4}

Get

static

const std::string Get

Defined in src/http/include/icy/http/request.h:28


{#head}

static

const std::string Head

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


{#put}

Put

static

const std::string Put

Defined in src/http/include/icy/http/request.h:30


{#post-2}

Post

static

const std::string Post

Defined in src/http/include/icy/http/request.h:31


{#options-3}

Options

static

const std::string Options

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


{#delete}

Delete

static

const std::string Delete

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


{#trace}

Trace

static

const std::string Trace

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


{#connect-13}

Connect

static

const std::string Connect

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

{#staticfileinfo}

StaticFileInfo

#include <icy/http/server.h>
struct StaticFileInfo

Defined in src/http/include/icy/http/server.h:261

Metadata needed to serve a static file with HTTP validators.

List of all members

NameKindOwner
sizevariableDeclared here
lastModifiedvariableDeclared here
etagvariableDeclared here

Public Attributes

ReturnNameDescription
uint64_tsizeFile size in bytes.
TimestamplastModifiedLast modification time, normalized to HTTP-second precision.
std::stringetagWeak validator suitable for ETag/If-None-Match.

{#size-2}

size

uint64_t size = 0

Defined in src/http/include/icy/http/server.h:263

File size in bytes.


{#lastmodified}

lastModified

Timestamp lastModified

Defined in src/http/include/icy/http/server.h:264

Last modification time, normalized to HTTP-second precision.


{#etag}

etag

std::string etag

Defined in src/http/include/icy/http/server.h:265

Weak validator suitable for ETag/If-None-Match.

{#ws}

ws

WebSocket framing, handshakes, and connection helpers.

Classes

NameDescription
WebSocketException
WebSocketFramerWebSocket frame encoder/decoder and handshake validator for RFC 6455.
WebSocketAdapterWebSocket protocol adapter for both client and server endpoints.
WebSocketStandalone WebSocket class.
ConnectionAdapterWebSocket class which belongs to an HTTP connection.

Enumerations

NameDescription
ModeWebSocket endpoint mode.
FrameFlagsFrame header flags.
OpcodeFrame header opcodes.
SendFlagsCombined header flags and opcodes for identifying the payload type of sent frames.
CloseStatusCodeStatusCodes for CLOSE frames sent with shutdown().
ErrorCodeThese error codes can be obtained from WebSocket exceptions to determine the exact cause of the error.
CloseState

{#mode-2}

Mode

enum Mode

WebSocket endpoint mode.

ValueDescription
ServerSideServer-side WebSocket.
ClientSideClient-side WebSocket.

{#frameflags}

FrameFlags

enum FrameFlags

Frame header flags.

ValueDescription
FinFIN bit: final fragment of a multi-fragment message.
Rsv1Reserved for future use. Must be zero.
Rsv2Reserved for future use. Must be zero.
Rsv3Reserved for future use. Must be zero.

{#opcode}

Opcode

enum Opcode

Frame header opcodes.

ValueDescription
ContinuationContinuation frame.
TextText frame.
BinaryBinary frame.
CloseClose connection.
PingPing frame.
PongPong frame.
BitmaskBit mask for opcodes.

{#sendflags}

SendFlags

enum SendFlags

Combined header flags and opcodes for identifying the payload type of sent frames.

ValueDescription
Text
Binary

{#closestatuscode}

CloseStatusCode

enum CloseStatusCode

StatusCodes for CLOSE frames sent with shutdown().

ValueDescription
NormalClose
EndpointGoingAway
ProtocolError
PayloadNotAcceptable
Reserved
ReservedNoStatusCode
ReservedAbnormalClose
MalformedPayload
PolicyViolation
PayloadTooBig
ExtensionRequired
UnexpectedCondition
ReservedTLSFailure

{#errorcode}

ErrorCode

enum ErrorCode

These error codes can be obtained from WebSocket exceptions to determine the exact cause of the error.

ValueDescription
NoHandshakeNo Connection: Upgrade or Upgrade: websocket header in handshake request.
HandshakeNoVersionNo Sec-WebSocket-Version header in handshake request.
HandshakeUnsupportedVersionUnsupported WebSocket version requested by client.
HandshakeNoKeyNo Sec-WebSocket-Key header in handshake request.
HandshakeAcceptNo Sec-WebSocket-Accept header or wrong value.
UnauthorizedThe server rejected the username or password for authentication.
PayloadTooBigPayload too big for supplied buffer.
IncompleteFrameIncomplete frame received.
InvalidRsvBitsRSV bits set without extension negotiation.
InvalidOpcodeUnknown or reserved opcode received.
UnmaskedClientFrameClient-to-server frame not masked (RFC 6455 violation).
ProtocolViolationGeneral RFC 6455 protocol violation.

{#closestate}

CloseState

enum CloseState
ValueDescription
Open
CloseSent
CloseReceived
Closed

Variables

ReturnNameDescription
autoServerSide static constexpr
autoClientSide static constexpr
charProtocolGuid constexpr
charProtocolVersion constexprThe WebSocket protocol version supported (13).

{#serverside}

ServerSide

static constexpr

auto ServerSide = 

{#clientside}

ClientSide

static constexpr

auto ClientSide = 

{#protocolguid}

ProtocolGuid

constexpr

char ProtocolGuid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"

{#protocolversion}

ProtocolVersion

constexpr

char ProtocolVersion = "13"

The WebSocket protocol version supported (13).

{#websocketexception}

WebSocketException

#include <icy/http/websocket.h>
class WebSocketException

Defined in src/http/include/icy/http/websocket.h:121

Inherits: runtime_error

List of all members

NameKindOwner
WebSocketExceptionfunctionDeclared here
codefunctionDeclared here
hasCloseStatusfunctionDeclared here
closeStatusfunctionDeclared here
_codevariableDeclared here
_closeStatusvariableDeclared here

Public Methods

ReturnNameDescription
WebSocketException inline
ErrorCodecode const inline nodiscard
boolhasCloseStatus const inline nodiscard
uint16_tcloseStatus const inline nodiscard

{#websocketexception-1}

WebSocketException

inline

inline WebSocketException(ErrorCode code, std::string message, uint16_t closeStatus = 0)

Defined in src/http/include/icy/http/websocket.h:124


{#code}

code

const inline nodiscard

[[nodiscard]] inline ErrorCode code() const

Defined in src/http/include/icy/http/websocket.h:131


{#hasclosestatus}

hasCloseStatus

const inline nodiscard

[[nodiscard]] inline bool hasCloseStatus() const

Defined in src/http/include/icy/http/websocket.h:132


{#closestatus}

closeStatus

const inline nodiscard

[[nodiscard]] inline uint16_t closeStatus() const

Defined in src/http/include/icy/http/websocket.h:133

Private Attributes

ReturnNameDescription
ErrorCode_code
uint16_t_closeStatus

{#_code}

_code

ErrorCode _code

Defined in src/http/include/icy/http/websocket.h:136


{#_closestatus}

_closeStatus

uint16_t _closeStatus

Defined in src/http/include/icy/http/websocket.h:137

{#websocketframer}

WebSocketFramer

#include <icy/http/websocket.h>
class WebSocketFramer

Defined in src/http/include/icy/http/websocket.h:156

WebSocket frame encoder/decoder and handshake validator for RFC 6455.

List of all members

NameKindOwner
WebSocketAdapterfriendDeclared here
wsFramerTestAccessfriendDeclared here
wsFramerGetFlagsfriendDeclared here
WebSocketFramerfunctionDeclared here
writeFramefunctionDeclared here
readFramefunctionDeclared here
handshakeCompletefunctionDeclared here
acceptServerRequestfunctionDeclared here
createClientHandshakeRequestfunctionDeclared here
checkClientHandshakeResponsefunctionDeclared here
completeClientHandshakefunctionDeclared here
frameFlagsfunctionDeclared here
mustMaskPayloadfunctionDeclared here
modefunctionDeclared here
_modevariableDeclared here
_frameFlagsvariableDeclared here
_headerStatevariableDeclared here
_maskPayloadvariableDeclared here
_rndvariableDeclared here
_keyvariableDeclared here
_fragmentedvariableDeclared here
_fragmentOpcodevariableDeclared here
_fragmentBuffervariableDeclared here
_incompleteFramevariableDeclared here

Friends

NameDescription
WebSocketAdapter
wsFramerTestAccess
wsFramerGetFlags

{#websocketadapter}

WebSocketAdapter

friend class WebSocketAdapter

Defined in src/http/include/icy/http/websocket.h:253


{#wsframertestaccess}

wsFramerTestAccess

friend void wsFramerTestAccess(WebSocketFramer & f, int state)

Defined in src/http/include/icy/http/websocket.h:256


{#wsframergetflags}

wsFramerGetFlags

friend int wsFramerGetFlags(const WebSocketFramer & f)

Defined in src/http/include/icy/http/websocket.h:257

Public Methods

ReturnNameDescription
WebSocketFramerCreates a WebSocketFramer operating in the given endpoint mode. Client-side framers mask outgoing payloads; server-side framers do not.
size_twriteFrame virtualEncodes data into a WebSocket frame and writes it to frame.
uint64_treadFrame virtualDecodes a single WebSocket frame from frame.
boolhandshakeComplete const nodiscardReturns true if the WebSocket handshake has completed successfully.
voidacceptServerRequestServer side.
voidcreateClientHandshakeRequestClient side.
boolcheckClientHandshakeResponseValidates the server's 101 Switching Protocols response.
voidcompleteClientHandshakeCompletes the client-side handshake by verifying Connection, Upgrade and Sec-WebSocket-Accept headers. Advances internal state to "complete".

{#websocketframer-1}

WebSocketFramer

WebSocketFramer(ws::Mode mode)

Defined in src/http/include/icy/http/websocket.h:162

Creates a WebSocketFramer operating in the given endpoint mode. Client-side framers mask outgoing payloads; server-side framers do not.

Parameters

  • mode ServerSide or ClientSide.

{#writeframe}

writeFrame

virtual

virtual size_t writeFrame(const char * data, size_t len, int flags, BitWriter & frame)

Defined in src/http/include/icy/http/websocket.h:173

Encodes data into a WebSocket frame and writes it to frame.

Parameters

Returns

Total number of bytes written to the frame buffer (header + payload).


{#readframe}

readFrame

virtual

virtual uint64_t readFrame(BitReader & frame, char *& payload)

Defined in src/http/include/icy/http/websocket.h:184

Decodes a single WebSocket frame from frame.

The payload is unmasked in-place in the source buffer; no copy is made. payload is set to point at the start of the payload within frame's buffer.

Parameters

  • frame BitReader positioned at the start of a frame.

  • payload Set to point at the start of the decoded payload. Not null-terminated.

Returns

Payload length in bytes.

Exceptions

  • std::runtime_error on protocol violations or if the buffer is too small.

{#handshakecomplete}

handshakeComplete

const nodiscard

[[nodiscard]] bool handshakeComplete() const

Defined in src/http/include/icy/http/websocket.h:187

Returns true if the WebSocket handshake has completed successfully.


{#acceptserverrequest}

acceptServerRequest

void acceptServerRequest(http::Request & request, http::Response & response)

Defined in src/http/include/icy/http/websocket.h:197

Server side.

Validates the client upgrade request and writes a 101 Switching Protocols response. Sets the internal state to mark the handshake as complete.

Parameters

  • request Incoming HTTP upgrade request.

  • response HTTP response to populate with the handshake reply.

Exceptions

  • std::runtime_error if the request is not a valid WebSocket upgrade.

{#createclienthandshakerequest}

createClientHandshakeRequest

void createClientHandshakeRequest(http::Request & request)

Defined in src/http/include/icy/http/websocket.h:205

Client side.

Populates request with the WebSocket upgrade headers (Connection, Upgrade, Sec-WebSocket-Key, Sec-WebSocket-Version) to initiate the handshake.

Parameters

  • request HTTP request to add upgrade headers to.

{#checkclienthandshakeresponse}

checkClientHandshakeResponse

bool checkClientHandshakeResponse(http::Response & response)

Defined in src/http/include/icy/http/websocket.h:211

Validates the server's 101 Switching Protocols response.

Parameters

  • response The HTTP response received from the server.

Returns

true if the handshake succeeded and data can flow.

Exceptions

  • std::runtime_error if the server rejected or mishandled the upgrade.

{#completeclienthandshake}

completeClientHandshake

void completeClientHandshake(http::Response & response)

Defined in src/http/include/icy/http/websocket.h:217

Completes the client-side handshake by verifying Connection, Upgrade and Sec-WebSocket-Accept headers. Advances internal state to "complete".

Parameters

  • response The 101 Switching Protocols response from the server.

Exceptions

  • std::runtime_error if any required header is missing or incorrect.

Protected Methods

ReturnNameDescription
intframeFlags const nodiscardReturns the frame flags of the most recently received frame. Set by readFrame()
boolmustMaskPayload const nodiscardReturns true if the payload must be masked. Used by writeFrame()
ws::Modemode const nodiscard

{#frameflags-1}

frameFlags

const nodiscard

[[nodiscard]] int frameFlags() const

Defined in src/http/include/icy/http/websocket.h:222

Returns the frame flags of the most recently received frame. Set by readFrame()


{#mustmaskpayload}

mustMaskPayload

const nodiscard

[[nodiscard]] bool mustMaskPayload() const

Defined in src/http/include/icy/http/websocket.h:226

Returns true if the payload must be masked. Used by writeFrame()


{#mode-3}

mode

const nodiscard

[[nodiscard]] ws::Mode mode() const

Defined in src/http/include/icy/http/websocket.h:228

Private Attributes

ReturnNameDescription
ws::Mode_mode
int_frameFlags
int_headerState
bool_maskPayload
Random_rnd
std::string_key
bool_fragmentedCurrently receiving a fragmented message.
int_fragmentOpcodeOpcode of the first frame in the fragment sequence.
Buffer_fragmentBufferAccumulated payload from continuation frames.
Buffer_incompleteFrameBuffer for incomplete frame data across TCP segments.

{#_mode-3}

_mode

ws::Mode _mode

Defined in src/http/include/icy/http/websocket.h:238


{#_frameflags}

_frameFlags

int _frameFlags

Defined in src/http/include/icy/http/websocket.h:239


{#_headerstate}

_headerState

int _headerState

Defined in src/http/include/icy/http/websocket.h:240


{#_maskpayload}

_maskPayload

bool _maskPayload

Defined in src/http/include/icy/http/websocket.h:241


{#_rnd}

_rnd

Random _rnd

Defined in src/http/include/icy/http/websocket.h:242


{#_key}

_key

std::string _key

Defined in src/http/include/icy/http/websocket.h:243


{#_fragmented}

_fragmented

bool _fragmented {false}

Defined in src/http/include/icy/http/websocket.h:246

Currently receiving a fragmented message.


{#_fragmentopcode}

_fragmentOpcode

int _fragmentOpcode {0}

Defined in src/http/include/icy/http/websocket.h:247

Opcode of the first frame in the fragment sequence.


{#_fragmentbuffer}

_fragmentBuffer

Buffer _fragmentBuffer

Defined in src/http/include/icy/http/websocket.h:248

Accumulated payload from continuation frames.


{#_incompleteframe}

_incompleteFrame

Buffer _incompleteFrame

Defined in src/http/include/icy/http/websocket.h:251

Buffer for incomplete frame data across TCP segments.

{#websocketadapter-1}

WebSocketAdapter

#include <icy/http/websocket.h>
class WebSocketAdapter

Defined in src/http/include/icy/http/websocket.h:267

Inherits: SocketEmitter Subclassed by: ConnectionAdapter, WebSocket

WebSocket protocol adapter for both client and server endpoints.

List of all members

NameKindOwner
WebSocketFramerfriendDeclared here
socketvariableDeclared here
WebSocketAdapterfunctionDeclared here
sendfunctionDeclared here
sendfunctionDeclared here
sendOwnedfunctionDeclared here
sendOwnedfunctionDeclared here
shutdownfunctionDeclared here
sendClientRequestfunctionDeclared here
handleClientResponsefunctionDeclared here
handleServerRequestfunctionDeclared here
onHandshakeCompletefunctionDeclared here
framervariableDeclared here
_requestvariableDeclared here
_responsevariableDeclared here
_closeStatevariableDeclared here
sendControlFramefunctionDeclared here
resetFrameStatefunctionDeclared here
onSocketConnectfunctionDeclared here
onSocketRecvfunctionDeclared here
onSocketClosefunctionDeclared here
ConnectvariableInherited from SocketEmitter
RecvvariableInherited from SocketEmitter
ErrorvariableInherited from SocketEmitter
ClosevariableInherited from SocketEmitter
implvariableInherited from SocketEmitter
SocketEmitterfunctionInherited from SocketEmitter
SocketEmitterfunctionInherited from SocketEmitter
~SocketEmitterfunctionInherited from SocketEmitter
addReceiverfunctionInherited from SocketEmitter
removeReceiverfunctionInherited from SocketEmitter
swapfunctionInherited from SocketEmitter
asfunctionInherited from SocketEmitter
operator->functionInherited from SocketEmitter
onSocketConnectfunctionInherited from SocketEmitter
onSocketRecvfunctionInherited from SocketEmitter
onSocketErrorfunctionInherited from SocketEmitter
onSocketClosefunctionInherited from SocketEmitter
priorityvariableInherited from SocketAdapter
SocketAdapterfunctionInherited from SocketAdapter
~SocketAdapterfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
setSenderfunctionInherited from SocketAdapter
senderfunctionInherited from SocketAdapter
addReceiverfunctionInherited from SocketAdapter
removeReceiverfunctionInherited from SocketAdapter
hasReceiverfunctionInherited from SocketAdapter
receiversfunctionInherited from SocketAdapter
onSocketConnectfunctionInherited from SocketAdapter
onSocketRecvfunctionInherited from SocketAdapter
onSocketErrorfunctionInherited from SocketAdapter
onSocketClosefunctionInherited from SocketAdapter
_sendervariableInherited from SocketAdapter
_receiversvariableInherited from SocketAdapter
_dirtyvariableInherited from SocketAdapter
cleanupReceiversfunctionInherited from SocketAdapter

Inherited from SocketEmitter

KindNameDescription
variableConnectSignals that the socket is connected.
variableRecvSignals when data is received by the socket.
variableErrorSignals that the socket is closed in error. This signal will be sent just before the Closed signal.
variableCloseSignals that the underlying socket is closed.
variableimplPointer to the underlying socket. Sent data will be proxied to this socket.
functionSocketEmitterCreates the SocketEmitter and optionally attaches it to a socket. If socket is provided, this emitter registers itself as a receiver.
functionSocketEmitterCopy constructor; copies all signal connections and attaches to the same socket.
function~SocketEmitter virtual noexceptDestroys the SocketAdapter.
functionaddReceiver virtual overrideAttaches a SocketAdapter as a receiver; wires it to all four socket signals.
functionremoveReceiver virtual overrideDetaches a SocketAdapter from all four socket signals.
functionswap virtualReplaces the underlying socket with socket.
functionas inlineReturns the underlying socket cast to type T, or nullptr if the cast fails.
functionoperator-> const inlineReturns a raw pointer to the underlying socket for direct method access. Follows shared_ptr semantics; the caller must not delete the returned pointer.
functiononSocketConnect virtual overrideForwards the connect event to chained adapters, then fires the Connect signal.
functiononSocketRecv virtual overrideForwards the recv event to chained adapters, then fires the Recv signal.
functiononSocketError virtual overrideForwards the error event to chained adapters, then fires the Error signal.
functiononSocketClose virtual overrideForwards the close event to chained adapters, then fires the Close signal.

Inherited from SocketAdapter

KindNameDescription
variablepriorityThe priority of this adapter for STL sort operations.
functionSocketAdapterCreates the SocketAdapter.
function~SocketAdapter virtual noexceptDestroys the SocketAdapter.
functionsend virtual nodiscardSends 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.
functionsend virtual nodiscard
functionsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
functionsendOwned virtual nodiscard
functionsendPacket virtualSends 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.
functionsendPacket virtual
functionsendPacket virtualSends 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.
functionsetSender virtualSets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
functionsenderReturns the output SocketAdapter pointer.
functionaddReceiver virtualSets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
functionremoveReceiver virtualRemove the given receiver.
functionhasReceiver virtualReturns true if the given receiver is connected.
functionreceiversReturns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
functiononSocketConnect virtualCalled 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.
functiononSocketRecv virtualCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtualCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtualCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
variable_sender
variable_receivers
variable_dirty
functioncleanupReceivers virtual

Friends

NameDescription
WebSocketFramer

{#websocketframer-2}

WebSocketFramer

friend class WebSocketFramer

Defined in src/http/include/icy/http/websocket.h:350

Public Attributes

ReturnNameDescription
net::Socket::PtrsocketPointer to the underlying socket. Sent data will be proxied to this socket.

{#socket-6}

socket

net::Socket::Ptr socket

Defined in src/http/include/icy/http/websocket.h:304

Pointer to the underlying socket. Sent data will be proxied to this socket.

Public Methods

ReturnNameDescription
WebSocketAdapterCreates a WebSocketAdapter using the given socket, mode and HTTP message objects.
ssize_tsend virtual overrideFrames and sends data to the peer's address.
ssize_tsend virtual overrideFrames and sends data to a specific peer address (for UDP-backed sockets).
ssize_tsendOwned virtual overrideSends an owned payload buffer to the connected peer.
ssize_tsendOwned virtual override
boolshutdown virtualSends a WebSocket CLOSE frame with the given status code and message, then closes the underlying socket.
voidsendClientRequest virtualClient side.
voidhandleClientResponse virtualParses the server's HTTP upgrade response and completes the handshake. Any data remaining in the buffer after the HTTP response is re-fed as WebSocket frames.
voidhandleServerRequest virtualServer side.
voidonHandshakeComplete virtualCalled when the WebSocket handshake completes. Emits the connect event to downstream handlers.

{#websocketadapter-2}

WebSocketAdapter

WebSocketAdapter(const net::Socket::Ptr & socket, ws::Mode mode, http::Request & request, http::Response & response)

Defined in src/http/include/icy/http/websocket.h:275

Creates a WebSocketAdapter using the given socket, mode and HTTP message objects.

Parameters

  • socket The underlying TCP or SSL socket.

  • mode ServerSide or ClientSide.

  • request HTTP request used for the handshake.

  • response HTTP response used for the handshake.


{#send-14}

send

virtual override

virtual ssize_t send(const char * data, size_t len, int flags = 0) override

Defined in src/http/include/icy/http/websocket.h:283

Frames and sends data to the peer's address.

Parameters

Returns

Number of bytes sent, or -1 on error.

Reimplements

{#send-15}

send

virtual override

virtual ssize_t send(const char * data, size_t len, const net::Address & peerAddr, int flags = 0) override

Defined in src/http/include/icy/http/websocket.h:291

Frames and sends data to a specific peer address (for UDP-backed sockets).

Parameters

Returns

Number of bytes sent, or -1 on error.

Reimplements

{#sendowned-12}

sendOwned

virtual override

virtual ssize_t sendOwned(Buffer && buffer, int flags = 0) override

Defined in src/http/include/icy/http/websocket.h:292

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

{#sendowned-13}

sendOwned

virtual override

virtual ssize_t sendOwned(Buffer && buffer, const net::Address & peerAddr, int flags = 0) override

Defined in src/http/include/icy/http/websocket.h:293

Reimplements

{#shutdown-8}

shutdown

virtual

virtual bool shutdown(uint16_t statusCode, const std::string & statusMessage)

Defined in src/http/include/icy/http/websocket.h:300

Sends a WebSocket CLOSE frame with the given status code and message, then closes the underlying socket.

Parameters

  • statusCode WebSocket close status code (e.g. 1000 for normal close).

  • statusMessage Human-readable reason for closing.

Returns

true if the close frame was sent successfully.


{#sendclientrequest}

sendClientRequest

virtual

virtual void sendClientRequest()

Defined in src/http/include/icy/http/websocket.h:311

Client side.

Sends the WebSocket HTTP upgrade request to initiate the handshake. Called automatically on socket connect.


{#handleclientresponse}

handleClientResponse

virtual

virtual void handleClientResponse(const MutableBuffer & buffer, const net::Address & peerAddr)

Defined in src/http/include/icy/http/websocket.h:317

Parses the server's HTTP upgrade response and completes the handshake. Any data remaining in the buffer after the HTTP response is re-fed as WebSocket frames.

Parameters

  • buffer Buffer containing the server's HTTP response.

  • peerAddr Address of the peer.


{#handleserverrequest}

handleServerRequest

virtual

virtual void handleServerRequest(const MutableBuffer & buffer, const net::Address & peerAddr)

Defined in src/http/include/icy/http/websocket.h:325

Server side.

Parses the client's HTTP upgrade request and sends the 101 response.

Parameters

  • buffer Buffer containing the client's HTTP upgrade request.

  • peerAddr Address of the peer.


{#onhandshakecomplete}

onHandshakeComplete

virtual

virtual void onHandshakeComplete()

Defined in src/http/include/icy/http/websocket.h:339

Called when the WebSocket handshake completes. Emits the connect event to downstream handlers.

Reimplemented by

Protected Attributes

ReturnNameDescription
WebSocketFramerframer
http::Request &_request
http::Response &_response
ws::CloseState_closeState

{#framer}

framer

WebSocketFramer framer

Defined in src/http/include/icy/http/websocket.h:352


{#_request-2}

_request

http::Request & _request

Defined in src/http/include/icy/http/websocket.h:353


{#_response-2}

_response

http::Response & _response

Defined in src/http/include/icy/http/websocket.h:354


{#_closestate}

_closeState

ws::CloseState _closeState {}

Defined in src/http/include/icy/http/websocket.h:355

Protected Methods

ReturnNameDescription
boolsendControlFrame
voidresetFrameState

{#sendcontrolframe}

sendControlFrame

bool sendControlFrame(ws::Opcode opcode, const char * payload, size_t payloadLen, const net::Address & peerAddr)

Defined in src/http/include/icy/http/websocket.h:344


{#resetframestate}

resetFrameState

void resetFrameState()

Defined in src/http/include/icy/http/websocket.h:348

Private Methods

ReturnNameDescription
boolonSocketConnect virtual overrideCalled by the socket on connect; initiates the client handshake.
boolonSocketRecv virtual overrideCalled by the socket on each received buffer; handles handshake or frame parsing depending on state.
boolonSocketClose virtual overrideCalled by the socket on close; resets framer state.

{#onsocketconnect-4}

onSocketConnect

virtual override

virtual bool onSocketConnect(net::Socket & socket) override

Defined in src/http/include/icy/http/websocket.h:328

Called by the socket on connect; initiates the client handshake.

Reimplements

{#onsocketrecv-6}

onSocketRecv

virtual override

virtual bool onSocketRecv(net::Socket & socket, const MutableBuffer & buffer, const net::Address & peerAddress) override

Defined in src/http/include/icy/http/websocket.h:332

Called by the socket on each received buffer; handles handshake or frame parsing depending on state.

Reimplements

{#onsocketclose-4}

onSocketClose

virtual override

virtual bool onSocketClose(net::Socket & socket) override

Defined in src/http/include/icy/http/websocket.h:335

Called by the socket on close; resets framer state.

Reimplements

{#websocket}

WebSocket

#include <icy/http/websocket.h>
class WebSocket

Defined in src/http/include/icy/http/websocket.h:365

Inherits: WebSocketAdapter

Standalone WebSocket class.

List of all members

NameKindOwner
WebSocketfunctionDeclared here
requestfunctionDeclared here
responsefunctionDeclared here
_requestvariableDeclared here
_responsevariableDeclared here
VectypedefDeclared here
WebSocketFramerfriendInherited from WebSocketAdapter
socketvariableInherited from WebSocketAdapter
WebSocketAdapterfunctionInherited from WebSocketAdapter
sendfunctionInherited from WebSocketAdapter
sendfunctionInherited from WebSocketAdapter
sendOwnedfunctionInherited from WebSocketAdapter
sendOwnedfunctionInherited from WebSocketAdapter
shutdownfunctionInherited from WebSocketAdapter
sendClientRequestfunctionInherited from WebSocketAdapter
handleClientResponsefunctionInherited from WebSocketAdapter
handleServerRequestfunctionInherited from WebSocketAdapter
onHandshakeCompletefunctionInherited from WebSocketAdapter
framervariableInherited from WebSocketAdapter
_requestvariableInherited from WebSocketAdapter
_responsevariableInherited from WebSocketAdapter
_closeStatevariableInherited from WebSocketAdapter
sendControlFramefunctionInherited from WebSocketAdapter
resetFrameStatefunctionInherited from WebSocketAdapter
onSocketConnectfunctionInherited from WebSocketAdapter
onSocketRecvfunctionInherited from WebSocketAdapter
onSocketClosefunctionInherited from WebSocketAdapter
ConnectvariableInherited from SocketEmitter
RecvvariableInherited from SocketEmitter
ErrorvariableInherited from SocketEmitter
ClosevariableInherited from SocketEmitter
implvariableInherited from SocketEmitter
SocketEmitterfunctionInherited from SocketEmitter
SocketEmitterfunctionInherited from SocketEmitter
~SocketEmitterfunctionInherited from SocketEmitter
addReceiverfunctionInherited from SocketEmitter
removeReceiverfunctionInherited from SocketEmitter
swapfunctionInherited from SocketEmitter
asfunctionInherited from SocketEmitter
operator->functionInherited from SocketEmitter
onSocketConnectfunctionInherited from SocketEmitter
onSocketRecvfunctionInherited from SocketEmitter
onSocketErrorfunctionInherited from SocketEmitter
onSocketClosefunctionInherited from SocketEmitter
priorityvariableInherited from SocketAdapter
SocketAdapterfunctionInherited from SocketAdapter
~SocketAdapterfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
setSenderfunctionInherited from SocketAdapter
senderfunctionInherited from SocketAdapter
addReceiverfunctionInherited from SocketAdapter
removeReceiverfunctionInherited from SocketAdapter
hasReceiverfunctionInherited from SocketAdapter
receiversfunctionInherited from SocketAdapter
onSocketConnectfunctionInherited from SocketAdapter
onSocketRecvfunctionInherited from SocketAdapter
onSocketErrorfunctionInherited from SocketAdapter
onSocketClosefunctionInherited from SocketAdapter
_sendervariableInherited from SocketAdapter
_receiversvariableInherited from SocketAdapter
_dirtyvariableInherited from SocketAdapter
cleanupReceiversfunctionInherited from SocketAdapter

Inherited from WebSocketAdapter

KindNameDescription
friendWebSocketFramer
variablesocketPointer to the underlying socket. Sent data will be proxied to this socket.
functionWebSocketAdapterCreates a WebSocketAdapter using the given socket, mode and HTTP message objects.
functionsend virtual overrideFrames and sends data to the peer's address.
functionsend virtual overrideFrames and sends data to a specific peer address (for UDP-backed sockets).
functionsendOwned virtual overrideSends an owned payload buffer to the connected peer.
functionsendOwned virtual override
functionshutdown virtualSends a WebSocket CLOSE frame with the given status code and message, then closes the underlying socket.
functionsendClientRequest virtualClient side.
functionhandleClientResponse virtualParses the server's HTTP upgrade response and completes the handshake. Any data remaining in the buffer after the HTTP response is re-fed as WebSocket frames.
functionhandleServerRequest virtualServer side.
functiononHandshakeComplete virtualCalled when the WebSocket handshake completes. Emits the connect event to downstream handlers.
variableframer
variable_request
variable_response
variable_closeState
functionsendControlFrame
functionresetFrameState
functiononSocketConnect virtual overrideCalled by the socket on connect; initiates the client handshake.
functiononSocketRecv virtual overrideCalled by the socket on each received buffer; handles handshake or frame parsing depending on state.
functiononSocketClose virtual overrideCalled by the socket on close; resets framer state.

Inherited from SocketEmitter

KindNameDescription
variableConnectSignals that the socket is connected.
variableRecvSignals when data is received by the socket.
variableErrorSignals that the socket is closed in error. This signal will be sent just before the Closed signal.
variableCloseSignals that the underlying socket is closed.
variableimplPointer to the underlying socket. Sent data will be proxied to this socket.
functionSocketEmitterCreates the SocketEmitter and optionally attaches it to a socket. If socket is provided, this emitter registers itself as a receiver.
functionSocketEmitterCopy constructor; copies all signal connections and attaches to the same socket.
function~SocketEmitter virtual noexceptDestroys the SocketAdapter.
functionaddReceiver virtual overrideAttaches a SocketAdapter as a receiver; wires it to all four socket signals.
functionremoveReceiver virtual overrideDetaches a SocketAdapter from all four socket signals.
functionswap virtualReplaces the underlying socket with socket.
functionas inlineReturns the underlying socket cast to type T, or nullptr if the cast fails.
functionoperator-> const inlineReturns a raw pointer to the underlying socket for direct method access. Follows shared_ptr semantics; the caller must not delete the returned pointer.
functiononSocketConnect virtual overrideForwards the connect event to chained adapters, then fires the Connect signal.
functiononSocketRecv virtual overrideForwards the recv event to chained adapters, then fires the Recv signal.
functiononSocketError virtual overrideForwards the error event to chained adapters, then fires the Error signal.
functiononSocketClose virtual overrideForwards the close event to chained adapters, then fires the Close signal.

Inherited from SocketAdapter

KindNameDescription
variablepriorityThe priority of this adapter for STL sort operations.
functionSocketAdapterCreates the SocketAdapter.
function~SocketAdapter virtual noexceptDestroys the SocketAdapter.
functionsend virtual nodiscardSends 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.
functionsend virtual nodiscard
functionsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
functionsendOwned virtual nodiscard
functionsendPacket virtualSends 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.
functionsendPacket virtual
functionsendPacket virtualSends 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.
functionsetSender virtualSets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
functionsenderReturns the output SocketAdapter pointer.
functionaddReceiver virtualSets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
functionremoveReceiver virtualRemove the given receiver.
functionhasReceiver virtualReturns true if the given receiver is connected.
functionreceiversReturns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
functiononSocketConnect virtualCalled 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.
functiononSocketRecv virtualCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtualCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtualCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
variable_sender
variable_receivers
variable_dirty
functioncleanupReceivers virtual

Public Methods

ReturnNameDescription
WebSocketCreates the WebSocket with the given Socket. The Socket should be a TCPSocket or a SSLSocket, depending on the protocol used (ws or wss).
http::Request &request nodiscardReturns the HTTP request used during the WebSocket handshake.
http::Response &response nodiscardReturns the HTTP response received during the WebSocket handshake.

{#websocket-1}

WebSocket

WebSocket(const net::Socket::Ptr & socket)

Defined in src/http/include/icy/http/websocket.h:373

Creates the WebSocket with the given Socket. The Socket should be a TCPSocket or a SSLSocket, depending on the protocol used (ws or wss).


{#request-11}

request

nodiscard

[[nodiscard]] http::Request & request()

Defined in src/http/include/icy/http/websocket.h:378

Returns the HTTP request used during the WebSocket handshake.


{#response-9}

response

nodiscard

[[nodiscard]] http::Response & response()

Defined in src/http/include/icy/http/websocket.h:381

Returns the HTTP response received during the WebSocket handshake.

Protected Attributes

ReturnNameDescription
http::Request_request
http::Response_response

{#_request-3}

_request

http::Request _request

Defined in src/http/include/icy/http/websocket.h:384


{#_response-3}

_response

http::Response _response

Defined in src/http/include/icy/http/websocket.h:385

Public Types

NameDescription
Vec

{#vec-4}

Vec

using Vec = std::vector< WebSocket >

Defined in src/http/include/icy/http/websocket.h:368

{#connectionadapter-3}

ConnectionAdapter

#include <icy/http/websocket.h>
class ConnectionAdapter

Defined in src/http/include/icy/http/websocket.h:395

Inherits: WebSocketAdapter

WebSocket class which belongs to an HTTP connection.

List of all members

NameKindOwner
ConnectionAdapterfunctionDeclared here
onHandshakeCompletefunctionDeclared here
_connectionvariableDeclared here
WebSocketFramerfriendInherited from WebSocketAdapter
socketvariableInherited from WebSocketAdapter
WebSocketAdapterfunctionInherited from WebSocketAdapter
sendfunctionInherited from WebSocketAdapter
sendfunctionInherited from WebSocketAdapter
sendOwnedfunctionInherited from WebSocketAdapter
sendOwnedfunctionInherited from WebSocketAdapter
shutdownfunctionInherited from WebSocketAdapter
sendClientRequestfunctionInherited from WebSocketAdapter
handleClientResponsefunctionInherited from WebSocketAdapter
handleServerRequestfunctionInherited from WebSocketAdapter
onHandshakeCompletefunctionInherited from WebSocketAdapter
framervariableInherited from WebSocketAdapter
_requestvariableInherited from WebSocketAdapter
_responsevariableInherited from WebSocketAdapter
_closeStatevariableInherited from WebSocketAdapter
sendControlFramefunctionInherited from WebSocketAdapter
resetFrameStatefunctionInherited from WebSocketAdapter
onSocketConnectfunctionInherited from WebSocketAdapter
onSocketRecvfunctionInherited from WebSocketAdapter
onSocketClosefunctionInherited from WebSocketAdapter
ConnectvariableInherited from SocketEmitter
RecvvariableInherited from SocketEmitter
ErrorvariableInherited from SocketEmitter
ClosevariableInherited from SocketEmitter
implvariableInherited from SocketEmitter
SocketEmitterfunctionInherited from SocketEmitter
SocketEmitterfunctionInherited from SocketEmitter
~SocketEmitterfunctionInherited from SocketEmitter
addReceiverfunctionInherited from SocketEmitter
removeReceiverfunctionInherited from SocketEmitter
swapfunctionInherited from SocketEmitter
asfunctionInherited from SocketEmitter
operator->functionInherited from SocketEmitter
onSocketConnectfunctionInherited from SocketEmitter
onSocketRecvfunctionInherited from SocketEmitter
onSocketErrorfunctionInherited from SocketEmitter
onSocketClosefunctionInherited from SocketEmitter
priorityvariableInherited from SocketAdapter
SocketAdapterfunctionInherited from SocketAdapter
~SocketAdapterfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
setSenderfunctionInherited from SocketAdapter
senderfunctionInherited from SocketAdapter
addReceiverfunctionInherited from SocketAdapter
removeReceiverfunctionInherited from SocketAdapter
hasReceiverfunctionInherited from SocketAdapter
receiversfunctionInherited from SocketAdapter
onSocketConnectfunctionInherited from SocketAdapter
onSocketRecvfunctionInherited from SocketAdapter
onSocketErrorfunctionInherited from SocketAdapter
onSocketClosefunctionInherited from SocketAdapter
_sendervariableInherited from SocketAdapter
_receiversvariableInherited from SocketAdapter
_dirtyvariableInherited from SocketAdapter
cleanupReceiversfunctionInherited from SocketAdapter

Inherited from WebSocketAdapter

KindNameDescription
friendWebSocketFramer
variablesocketPointer to the underlying socket. Sent data will be proxied to this socket.
functionWebSocketAdapterCreates a WebSocketAdapter using the given socket, mode and HTTP message objects.
functionsend virtual overrideFrames and sends data to the peer's address.
functionsend virtual overrideFrames and sends data to a specific peer address (for UDP-backed sockets).
functionsendOwned virtual overrideSends an owned payload buffer to the connected peer.
functionsendOwned virtual override
functionshutdown virtualSends a WebSocket CLOSE frame with the given status code and message, then closes the underlying socket.
functionsendClientRequest virtualClient side.
functionhandleClientResponse virtualParses the server's HTTP upgrade response and completes the handshake. Any data remaining in the buffer after the HTTP response is re-fed as WebSocket frames.
functionhandleServerRequest virtualServer side.
functiononHandshakeComplete virtualCalled when the WebSocket handshake completes. Emits the connect event to downstream handlers.
variableframer
variable_request
variable_response
variable_closeState
functionsendControlFrame
functionresetFrameState
functiononSocketConnect virtual overrideCalled by the socket on connect; initiates the client handshake.
functiononSocketRecv virtual overrideCalled by the socket on each received buffer; handles handshake or frame parsing depending on state.
functiononSocketClose virtual overrideCalled by the socket on close; resets framer state.

Inherited from SocketEmitter

KindNameDescription
variableConnectSignals that the socket is connected.
variableRecvSignals when data is received by the socket.
variableErrorSignals that the socket is closed in error. This signal will be sent just before the Closed signal.
variableCloseSignals that the underlying socket is closed.
variableimplPointer to the underlying socket. Sent data will be proxied to this socket.
functionSocketEmitterCreates the SocketEmitter and optionally attaches it to a socket. If socket is provided, this emitter registers itself as a receiver.
functionSocketEmitterCopy constructor; copies all signal connections and attaches to the same socket.
function~SocketEmitter virtual noexceptDestroys the SocketAdapter.
functionaddReceiver virtual overrideAttaches a SocketAdapter as a receiver; wires it to all four socket signals.
functionremoveReceiver virtual overrideDetaches a SocketAdapter from all four socket signals.
functionswap virtualReplaces the underlying socket with socket.
functionas inlineReturns the underlying socket cast to type T, or nullptr if the cast fails.
functionoperator-> const inlineReturns a raw pointer to the underlying socket for direct method access. Follows shared_ptr semantics; the caller must not delete the returned pointer.
functiononSocketConnect virtual overrideForwards the connect event to chained adapters, then fires the Connect signal.
functiononSocketRecv virtual overrideForwards the recv event to chained adapters, then fires the Recv signal.
functiononSocketError virtual overrideForwards the error event to chained adapters, then fires the Error signal.
functiononSocketClose virtual overrideForwards the close event to chained adapters, then fires the Close signal.

Inherited from SocketAdapter

KindNameDescription
variablepriorityThe priority of this adapter for STL sort operations.
functionSocketAdapterCreates the SocketAdapter.
function~SocketAdapter virtual noexceptDestroys the SocketAdapter.
functionsend virtual nodiscardSends 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.
functionsend virtual nodiscard
functionsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
functionsendOwned virtual nodiscard
functionsendPacket virtualSends 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.
functionsendPacket virtual
functionsendPacket virtualSends 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.
functionsetSender virtualSets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
functionsenderReturns the output SocketAdapter pointer.
functionaddReceiver virtualSets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
functionremoveReceiver virtualRemove the given receiver.
functionhasReceiver virtualReturns true if the given receiver is connected.
functionreceiversReturns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
functiononSocketConnect virtualCalled 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.
functiononSocketRecv virtualCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtualCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtualCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
variable_sender
variable_receivers
variable_dirty
functioncleanupReceivers virtual

Public Methods

ReturnNameDescription
ConnectionAdapterCreates a ConnectionAdapter for upgrading an existing HTTP connection to WebSocket. Disables automatic header sending on the underlying connection.
voidonHandshakeComplete virtualCalled when the WebSocket handshake completes. Emits the connect event via the socket emitter chain.

{#connectionadapter-4}

ConnectionAdapter

ConnectionAdapter(Connection * connection, ws::Mode mode)

Defined in src/http/include/icy/http/websocket.h:402

Creates a ConnectionAdapter for upgrading an existing HTTP connection to WebSocket. Disables automatic header sending on the underlying connection.

Parameters

  • connection The HTTP connection to upgrade.

  • mode ServerSide or ClientSide.


{#onhandshakecomplete-1}

onHandshakeComplete

virtual

virtual void onHandshakeComplete()

Defined in src/http/include/icy/http/websocket.h:407

Called when the WebSocket handshake completes. Emits the connect event via the socket emitter chain.

Reimplements

Protected Attributes

ReturnNameDescription
Connection *_connection

{#_connection-3}

_connection

Connection * _connection

Defined in src/http/include/icy/http/websocket.h:410