http
May 15, 2026 ยท View on GitHub
{#httpmodule}
http
HTTP client/server, WebSocket support, form handling, cookies, URL parsing.
Namespaces
| Name | Description |
|---|---|
http | HTTP request/response types, parsers, and server/client helpers. |
ws | WebSocket framing, handshakes, and connection helpers. |
{#http}
http
HTTP request/response types, parsers, and server/client helpers.
Classes
| Name | Description |
|---|---|
Authenticator | Maintains HTTP Basic or Digest authentication state for outbound requests. |
BasicAuthenticator | Encodes and decodes HTTP Basic authentication credentials. |
ChunkedAdapter | HTTP chunked transfer encoding adapter for streaming responses. |
Client | HTTP client for creating and managing outgoing connections. |
ClientConnection | HTTP client connection for managing request/response lifecycle. |
Connection | Base HTTP connection managing socket I/O and message lifecycle |
ConnectionAdapter | Default HTTP socket adapter for reading and writing HTTP messages |
ConnectionPool | LIFO connection pool for reusing ServerConnection objects. Avoids per-request heap allocation by resetting and reusing connections instead of destroying and recreating them. |
ConnectionStream | Packet stream wrapper for an HTTP connection. |
Cookie | HTTP cookie value plus its response/header attributes. |
FilePart | Form part backed by a file on disk. |
FormPart | An implementation of FormPart. |
FormWriter | FormWriter is an HTTP client connection adapter for writing HTML forms. |
Message | The base class for Request and Response. |
MultipartAdapter | HTTP multipart encoding adapter for multipart/x-mixed-replace streaming. |
Parser | HTTP request/response parser using the llhttp library. |
ParserObserver | Abstract observer interface for HTTP parser events. |
ProgressSignal | HTTP progress signal for upload and download progress notifications. |
Request | HTTP request message with method, URI, headers, and optional body. |
Response | HTTP response message with status, reason phrase, headers, and body metadata. |
Server | HTTP server implementation. |
ServerConnection | HTTP server connection. |
ServerConnectionFactory | Factory for creating per-socket [ServerConnection](#serverconnection-1) and per-request [ServerResponder](#serverresponder) objects. |
ServerResponder | Base responder interface for handling one HTTP request on a server connection. Derived classes typically override [onRequest()](#onrequest) and optionally the streaming hooks. |
StringPart | Form part backed by an in-memory string payload. |
URL | An RFC 3986 based URL parser. Constructors and assignment operators will throw a SyntaxException if the URL is invalid. |
DateCache | Caches the formatted Date header, updated once per second. Avoids per-request time formatting and string allocation. |
Method | HTTP request methods. |
StaticFileInfo | Metadata needed to serve a static file with HTTP validators. |
Enumerations
| Name | Description |
|---|---|
StatusCode | HTTP Response Status Codes. |
ServerConnectionState | HTTP server-side lifecycle phases used by the keep-alive state machine. |
ServerConnectionMode | Transport mode for server connections before and after protocol upgrade. |
{#statuscode}
StatusCode
enum StatusCode
HTTP Response Status Codes.
| Value | Description |
|---|---|
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.
| Value | Description |
|---|---|
ReceivingHeaders | Parsing request headers. |
ReceivingBody | Receiving request body bytes. |
DispatchingOrSending | Dispatching the responder or sending a normal response. |
Streaming | Sending a long-lived streaming response. |
Upgraded | Upgraded to a non-HTTP protocol such as WebSocket. |
Closing | Close has been requested and teardown is in progress. |
Closed | Connection has fully closed. |
{#serverconnectionmode}
ServerConnectionMode
enum ServerConnectionMode
Transport mode for server connections before and after protocol upgrade.
| Value | Description |
|---|---|
Http | Standard HTTP request/response mode. |
Upgraded | Upgraded transport mode owned by another protocol adapter. |
Typedefs
| Return | Name | Description |
|---|---|---|
std::vector< ClientConnection::Ptr > | ClientConnectionPtrVec | List 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
| Return | Name | Description |
|---|---|---|
bool | isBasicCredentials nodiscard | Returns true if the given Authorization header value uses HTTP Basic authentication. |
bool | isDigestCredentials nodiscard | Returns true if the given Authorization header value uses HTTP Digest authentication. |
bool | hasBasicCredentials nodiscard | Returns true if the request contains a Basic Authorization header. |
bool | hasDigestCredentials nodiscard | Returns true if the request contains a Digest Authorization header. |
bool | hasProxyBasicCredentials nodiscard | Returns true if the request contains a Basic Proxy-Authorization header. |
bool | hasProxyDigestCredentials nodiscard | Returns true if the request contains a Digest Proxy-Authorization header. |
void | extractCredentials | 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. |
void | extractCredentials | Extracts username and password from the user-info component of a URL. Does nothing if the URL has no user-info part. |
ClientConnection::Ptr | createConnectionT inline | 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: |
ClientConnection::Ptr | createConnection inline | Creates 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 nodiscard | Returns the standard reason phrase for the given HTTP status code (e.g. "OK" for StatusCode::OK, "Not Found" for StatusCode::NotFound). |
const char * | getStatusCodeString nodiscard | Returns a combined "NNN Reason" string for the given HTTP status code (e.g. "200 OK"). |
bool | statStaticFile | Read static-file metadata from disk. |
bool | prepareStaticFileResponse | Apply static-file headers and request conditionals to the response. |
std::string | parseURI | Extracts the URI (path and query) from a raw HTTP request line. |
bool | matchURL | Tests whether a URI matches a glob-style expression. |
std::string | parseCookieItem | Extracts a named attribute from a Cookie header value. |
bool | splitURIParameters | Parses URL query parameters from a URI into key-value pairs. Handles percent-decoding of names and values. |
void | splitParameters | Splits a header-style parameter string into a primary value and named attributes. Attributes are separated by ';'. Enclosing quotes are stripped from values. |
void | splitParameters | Splits 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
headerValue 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
headerValue 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
requestHTTP request to inspect.
{#hasdigestcredentials}
hasDigestCredentials
nodiscard
[[nodiscard]] bool hasDigestCredentials(const http::Request & request)
Returns true if the request contains a Digest Authorization header.
Parameters
requestHTTP 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
requestHTTP 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
requestHTTP 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
-
userInfoInput string in the form "user:password". -
usernameReceives the extracted username. -
passwordReceives 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
-
uriURL to extract credentials from. -
usernameReceives the extracted username. -
passwordReceives 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
ConnectionTConcrete connection type derived from ClientConnection.
Parameters
-
urlTarget URL. Must have a recognised scheme. -
loopEvent loop to use. Defaults to the default libuv loop.
Returns
Shared pointer to the created connection.
Exceptions
std::runtime_errorif 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
-
urlTarget URL. The scheme determines the socket and adapter type. -
clientOptional Client instance to register the connection with. -
loopEvent 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
statusHTTP 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
statusHTTP 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
-
pathFile path on disk. -
infoReceives 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
-
requestIncoming HTTP request. -
responseOutgoing HTTP response to update. -
infoPrecomputed 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
requestRaw 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
-
uriThe URI to test. -
expressionPattern 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
-
cookieFull Cookie header value (e.g. "name=value; Path=/; HttpOnly"). -
itemAttribute 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
-
uriURI string optionally containing a '?' query component. -
outCollection 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
-
sInput string to split. -
valueReceives the primary value before the first ';'. -
parametersReceives 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
-
beginIterator to the start of the string to parse. -
endIterator past the end of the string to parse. -
parametersReceives 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
| Name | Kind | Owner |
|---|---|---|
Authenticator | function | Declared here |
Authenticator | function | Declared here |
~Authenticator | function | Declared here |
fromUserInfo | function | Declared here |
fromURI | function | Declared here |
setUsername | function | Declared here |
username | function | Declared here |
setPassword | function | Declared here |
password | function | Declared here |
authenticate | function | Declared here |
updateAuthInfo | function | Declared here |
proxyAuthenticate | function | Declared here |
updateProxyAuthInfo | function | Declared here |
_username | variable | Declared here |
_password | variable | Declared here |
Authenticator | function | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
Authenticator | Creates an empty authenticator. | |
Authenticator | Creates an authenticator with the given username and password. | |
~Authenticator | Destroys the authenticator. | |
void | fromUserInfo | Parses username:password std::string and sets username and password of the credentials object. Throws SyntaxException on invalid user information. |
void | fromURI | 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. |
void | setUsername | Sets the username. |
const std::string & | username const nodiscard | Returns the username. |
void | setPassword | Sets the password. |
const std::string & | password const nodiscard | Returns the password. |
void | authenticate | 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. |
void | updateAuthInfo | Updates internal state (in case of digest authentication) and replaces authentication information in the request accordingly. |
void | proxyAuthenticate | 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. |
void | updateProxyAuthInfo | Updates 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
| Return | Name | Description |
|---|---|---|
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
| Return | Name | Description |
|---|---|---|
Authenticator | Deleted 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
| Name | Kind | Owner |
|---|---|---|
BasicAuthenticator | function | Declared here |
BasicAuthenticator | function | Declared here |
BasicAuthenticator | function | Declared here |
BasicAuthenticator | function | Declared here |
~BasicAuthenticator | function | Declared here |
setUsername | function | Declared here |
username | function | Declared here |
setPassword | function | Declared here |
password | function | Declared here |
authenticate | function | Declared here |
proxyAuthenticate | function | Declared here |
parseAuthInfo | function | Declared here |
_username | variable | Declared here |
_password | variable | Declared here |
BasicAuthenticator | function | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
BasicAuthenticator | Creates an empty basic authenticator. | |
BasicAuthenticator | Creates a basic authenticator with the given username and password. | |
BasicAuthenticator explicit | Extracts basic authentication credentials from the given request. | |
BasicAuthenticator explicit | Parses a raw Basic authentication payload string. The value can be extracted from a request via [Request::getCredentials()](#getcredentials). | |
~BasicAuthenticator | Destroys the basic authenticator. | |
void | setUsername | Sets the username. |
const std::string & | username const nodiscard | Returns the username. |
void | setPassword | Sets the password. |
const std::string & | password const nodiscard | Returns the password. |
void | authenticate const | Adds authentication information to the given http::Request. |
void | proxyAuthenticate const | Adds 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
| Return | Name | Description |
|---|---|---|
void | parseAuthInfo | Extracts 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
| Return | Name | Description |
|---|---|---|
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
| Return | Name | Description |
|---|---|---|
BasicAuthenticator | Deleted 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
| Name | Kind | Owner |
|---|---|---|
connection | variable | Declared here |
contentType | variable | Declared here |
frameSeparator | variable | Declared here |
initial | variable | Declared here |
nocopy | variable | Declared here |
emitter | variable | Declared here |
ChunkedAdapter | function | Declared here |
ChunkedAdapter | function | Declared here |
emitHeader | function | Declared here |
process | function | Declared here |
PacketProcessor | function | Inherited from PacketProcessor |
process | function | Inherited from PacketProcessor |
accepts | function | Inherited from PacketProcessor |
operator<< | function | Inherited from PacketProcessor |
_emitter | variable | Inherited from PacketStreamAdapter |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
~PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
getEmitter | function | Inherited from PacketStreamAdapter |
retention | function | Inherited from PacketStreamAdapter |
onStreamStateChange | function | Inherited from PacketStreamAdapter |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
operator= | function | Inherited from PacketStreamAdapter |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
operator= | function | Inherited from PacketStreamAdapter |
Inherited from PacketProcessor
| Kind | Name | Description |
|---|---|---|
function | PacketProcessor inline | |
function | process virtual | This method performs processing on the given packet and emits the result. |
function | accepts virtual inline | This method ensures compatibility with the given packet type. Return false to reject the packet. |
function | operator<< virtual inline | Stream operator alias for process(). |
Inherited from PacketStreamAdapter
| Kind | Name | Description |
|---|---|---|
variable | _emitter | |
function | PacketStreamAdapter | Construct the adapter, binding it to the given packet signal. |
function | ~PacketStreamAdapter virtual inline | |
function | emit virtual | Emit a mutable raw buffer as a packet. |
function | emit virtual | Emit a read-only raw buffer as a packet (data is copied internally). |
function | emit virtual | Emit a string as a packet (data is copied internally). |
function | emit virtual | Emit a flag-only packet carrying no payload data. |
function | emit virtual | Emit an existing packet directly onto the outgoing signal. |
function | getEmitter | Returns a reference to the outgoing packet signal. |
function | retention virtual const nodiscard | Returns 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. |
function | onStreamStateChange virtual inline | Called 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. |
function | PacketStreamAdapter | NonCopyable and NonMovable. |
function | operator= | Deleted assignment operator. |
function | PacketStreamAdapter | Deleted constructor. |
function | operator= | Deleted assignment operator. |
Public Attributes
| Return | Name | Description |
|---|---|---|
Connection::Ptr | connection | HTTP connection to send the initial response header through. |
std::string | contentType | Content-Type value for the chunked response. |
std::string | frameSeparator | Optional separator written before each chunk payload. |
bool | initial | True until the first chunk is processed and the header emitted. |
bool | nocopy | If true, header/data/footer are emitted as separate packets. |
PacketSignal | emitter |
{#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
| Return | Name | Description |
|---|---|---|
ChunkedAdapter inline | Creates a ChunkedAdapter that sends its initial response header through the given connection. The content type is read from the connection's outgoing header. | |
ChunkedAdapter inline | Creates a ChunkedAdapter that emits its own raw HTTP/1.1 200 response header. Use this when no Connection object is available. | |
void | emitHeader virtual inline | 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. |
void | process virtual inline override | Encodes 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
-
connectionHTTP connection to use. May be nullptr to emit a raw response instead. -
frameSeparatorOptional data prepended to each chunk payload. -
nocopyIf 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
-
contentTypeContent-Type value for the response. -
frameSeparatorOptional data prepended to each chunk payload. -
nocopyIf 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
packetPacket containing the raw payload data.
Exceptions
std::invalid_argumentif 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
| Name | Kind | Owner |
|---|---|---|
ClientConnection | friend | Declared here |
Shutdown | variable | Declared here |
Client | function | Declared here |
stop | function | Declared here |
createConnectionT | function | Declared here |
createConnection | function | Declared here |
addConnection | function | Declared here |
removeConnection | function | Declared here |
instance | function | Declared here |
destroy | function | Declared here |
_connections | variable | Declared here |
onConnectionClose | function | Declared here |
Friends
| Name | Description |
|---|---|
ClientConnection |
{#clientconnection}
ClientConnection
friend class ClientConnection
Defined in src/http/include/icy/http/client.h:252
Public Attributes
| Return | Name | Description |
|---|---|---|
NullSignal | Shutdown |
{#shutdown-6}
Shutdown
NullSignal Shutdown
Defined in src/http/include/icy/http/client.h:247
Public Methods
| Return | Name | Description |
|---|---|---|
Client | ||
void | stop | Stop the Client and close all connections. |
ClientConnection::Ptr | createConnectionT inline | Creates and registers a typed client connection for the given URL. The connection type is inferred from the URL scheme (http, https, ws, wss). |
ClientConnection::Ptr | createConnection inline | Creates and registers a ClientConnection for the given URL. The socket type is chosen based on the URL scheme (http/https/ws/wss). |
void | addConnection virtual | Registers a connection with this client so it is tracked and cleaned up on stop(). |
void | removeConnection virtual | Removes 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
ConnectionTConcrete connection type derived from ClientConnection.
Parameters
-
urlTarget URL. The scheme determines the socket and adapter type. -
loopEvent 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
-
urlTarget URL. -
loopEvent 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
connThe 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
connRaw pointer to the connection to remove.
Exceptions
std::logic_errorif the connection is not tracked by this client.
Public Static Methods
| Return | Name | Description |
|---|---|---|
Client & | instance static | Return the default HTTP Client singleton. |
void | destroy static | Destroys 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
| Return | Name | Description |
|---|---|---|
ClientConnectionPtrVec | _connections |
{#_connections}
_connections
ClientConnectionPtrVec _connections
Defined in src/http/include/icy/http/client.h:254
Protected Methods
| Return | Name | Description |
|---|---|---|
void | onConnectionClose |
{#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
| Name | Kind | Owner |
|---|---|---|
opaque | variable | Declared here |
Connect | variable | Declared here |
Headers | variable | Declared here |
Payload | variable | Declared here |
Complete | variable | Declared here |
Error | variable | Declared here |
Close | variable | Declared here |
IncomingProgress | variable | Declared here |
ClientConnection | function | Declared here |
start | function | Declared here |
start | function | Declared here |
send | function | Declared here |
setReadStream | function | Declared here |
readStream | function | Declared here |
_url | variable | Declared here |
_connect | variable | Declared here |
_active | variable | Declared here |
_complete | variable | Declared here |
_outgoingBuffer | variable | Declared here |
_readStream | variable | Declared here |
connect | function | Declared here |
incomingHeader | function | Declared here |
outgoingHeader | function | Declared here |
onSocketConnect | function | Declared here |
Ptr | typedef | Declared here |
onHeaders | function | Declared here |
onPayload | function | Declared here |
onComplete | function | Declared here |
onClose | function | Declared here |
onSocketError | function | Declared here |
ConnectionStream | friend | Inherited from Connection |
ConnectionAdapter | friend | Inherited from Connection |
Connection | function | Inherited from Connection |
onHeaders | function | Inherited from Connection |
onPayload | function | Inherited from Connection |
onComplete | function | Inherited from Connection |
onClose | function | Inherited from Connection |
send | function | Inherited from Connection |
sendOwned | function | Inherited from Connection |
sendHeader | function | Inherited from Connection |
close | function | Inherited from Connection |
markActive | function | Inherited from Connection |
beginStreaming | function | Inherited from Connection |
endStreaming | function | Inherited from Connection |
closed | function | Inherited from Connection |
error | function | Inherited from Connection |
headerAutoSendEnabled | function | Inherited from Connection |
setHeaderAutoSendEnabled | function | Inherited from Connection |
replaceAdapter | function | Inherited from Connection |
replaceAdapter | function | Inherited from Connection |
secure | function | Inherited from Connection |
socket | function | Inherited from Connection |
adapter | function | Inherited from Connection |
request | function | Inherited from Connection |
response | function | Inherited from Connection |
incomingHeader | function | Inherited from Connection |
outgoingHeader | function | Inherited from Connection |
_socket | variable | Inherited from Connection |
_adapter | variable | Inherited from Connection |
_request | variable | Inherited from Connection |
_response | variable | Inherited from Connection |
_error | variable | Inherited from Connection |
_closed | variable | Inherited from Connection |
_shouldSendHeader | variable | Inherited from Connection |
setError | function | Inherited from Connection |
onSocketConnect | function | Inherited from Connection |
onSocketRecv | function | Inherited from Connection |
onSocketError | function | Inherited from Connection |
onSocketClose | function | Inherited from Connection |
Ptr | typedef | Inherited from Connection |
priority | variable | Inherited from SocketAdapter |
SocketAdapter | function | Inherited from SocketAdapter |
~SocketAdapter | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
setSender | function | Inherited from SocketAdapter |
sender | function | Inherited from SocketAdapter |
addReceiver | function | Inherited from SocketAdapter |
removeReceiver | function | Inherited from SocketAdapter |
hasReceiver | function | Inherited from SocketAdapter |
receivers | function | Inherited from SocketAdapter |
onSocketConnect | function | Inherited from SocketAdapter |
onSocketRecv | function | Inherited from SocketAdapter |
onSocketError | function | Inherited from SocketAdapter |
onSocketClose | function | Inherited from SocketAdapter |
_sender | variable | Inherited from SocketAdapter |
_receivers | variable | Inherited from SocketAdapter |
_dirty | variable | Inherited from SocketAdapter |
cleanupReceivers | function | Inherited from SocketAdapter |
Inherited from Connection
| Kind | Name | Description |
|---|---|---|
friend | ConnectionStream | |
friend | ConnectionAdapter | |
function | Connection | Creates a Connection using the given TCP socket. |
function | onHeaders virtual | Called when the incoming HTTP headers have been fully parsed. |
function | onPayload virtual | Called for each chunk of incoming body data after headers are complete. |
function | onComplete virtual | Called when the incoming HTTP message is fully received. |
function | onClose virtual | Called when the connection is closed. |
function | send virtual override | Send raw data to the peer. |
function | sendOwned virtual override | Send an owned payload buffer to the peer. |
function | sendHeader virtual | Send the outdoing HTTP header. |
function | close virtual | Close the connection and schedule the object for deferred deletion. |
function | markActive virtual inline | Marks the connection as active. Server connections override this to refresh the idle timer. |
function | beginStreaming virtual inline | Explicitly enter long-lived streaming mode. Base connections ignore this; server connections use it to disable keep-alive idle reaping while a response stream is active. |
function | endStreaming virtual inline | Exit long-lived streaming mode. |
function | closed const nodiscard | Return true if the connection is closed. |
function | error const nodiscard | Return the error object if any. |
function | headerAutoSendEnabled const nodiscard | Return true if headers should be automatically sent. |
function | setHeaderAutoSendEnabled | Enable or disable automatic header emission for the next outgoing send path. |
function | replaceAdapter virtual | Assign the new ConnectionAdapter and setup the chain. The flow is: Connection <-> ConnectionAdapter <-> Socket. Takes ownership of the adapter (deferred deletion via uv loop). |
function | replaceAdapter virtual | Overload for nullptr (used in destructor to clear adapter). |
function | secure const nodiscard | Return true if the connection uses TLS/SSL. |
function | socket nodiscard | Return the underlying socket pointer. |
function | adapter const nodiscard | Return the underlying adapter pointer. |
function | request nodiscard | The HTTP request headers. |
function | response nodiscard | The HTTP response headers. |
function | incomingHeader virtual | Returns the incoming HTTP message header (request or response depending on role). |
function | outgoingHeader virtual | Returns the outgoing HTTP message header (request or response depending on role). |
variable | _socket | |
variable | _adapter | |
variable | _request | |
variable | _response | |
variable | _error | |
variable | _closed | |
variable | _shouldSendHeader | |
function | setError virtual | Set the internal error. Note: Setting the error does not [close()](#close-20) the connection. |
function | onSocketConnect virtual override | net::SocketAdapter interface |
function | onSocketRecv virtual override | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual override | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual override | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
typedef | Ptr |
Inherited from SocketAdapter
| Kind | Name | Description |
|---|---|---|
variable | priority | The priority of this adapter for STL sort operations. |
function | SocketAdapter | Creates the SocketAdapter. |
function | ~SocketAdapter virtual noexcept | Destroys the SocketAdapter. |
function | send virtual nodiscard | Sends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | send virtual nodiscard | |
function | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual nodiscard | |
function | sendPacket virtual | Sends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | sendPacket virtual | |
function | sendPacket virtual | Sends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed. |
function | setSender virtual | Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default. |
function | sender | Returns the output SocketAdapter pointer. |
function | addReceiver virtual | Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default. |
function | removeReceiver virtual | Remove the given receiver. |
function | hasReceiver virtual | Returns true if the given receiver is connected. |
function | receivers | Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list. |
function | onSocketConnect virtual | Called when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event. |
function | onSocketRecv virtual | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
variable | _sender | |
variable | _receivers | |
variable | _dirty | |
function | cleanupReceivers virtual |
Public Attributes
| Return | Name | Description |
|---|---|---|
void * | opaque | Optional unmanaged client data pointer. Not used by the connection internally. |
NullSignal | Connect | Status signals. |
Signal< void(Response &)> | Headers | Signals when the response HTTP header has been received. |
Signal< void(const MutableBuffer &)> | Payload | Signals when raw data is received. |
Signal< void(const Response &)> | Complete | Signals when the HTTP transaction is complete. |
Signal< void(const icy::Error &)> | Error | Signals when the underlying transport reports an error. |
Signal< void(Connection &)> | Close | Signals when the connection is closed. |
ProgressSignal | IncomingProgress | Signals 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
| Return | Name | Description |
|---|---|---|
ClientConnection | 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. | |
void | start virtual | Starts the internal HTTP request. |
void | start virtual | Starts the given HTTP request, replacing the internal request object. |
ssize_t | send virtual override | Sends raw data to the peer, initiating a connection first if needed. Data is buffered internally until the connection is established. |
void | setReadStream virtual | 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(). |
StreamT & | readStream inline | Returns 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
-
urlTarget URL. Scheme, host, port and path are extracted automatically. -
socketTCP 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_errorif 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
reqThe HTTP request to send. Replaces the internal request.
Exceptions
std::runtime_errorif 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
-
dataPointer to the data buffer. -
lenNumber of bytes to send. -
flagsSocket 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
osPointer to the output stream. Takes ownership.
Exceptions
std::runtime_errorif 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
StreamTThe concrete stream type to cast to.
Returns
Reference to the stream.
Exceptions
-
std::runtime_errorif no read stream has been set. -
std::bad_castif the stream is not of type StreamT.
Protected Attributes
| Return | Name | Description |
|---|---|---|
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
| Return | Name | Description |
|---|---|---|
void | connect virtual | Connects to the server endpoint. All sent data is buffered until the connection is made. |
http::Message * | incomingHeader virtual override | Returns the incoming HTTP message header (request or response depending on role). |
http::Message * | outgoingHeader virtual override | Returns the outgoing HTTP message header (request or response depending on role). |
bool | onSocketConnect virtual override | net::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
| Name | Description |
|---|---|
Ptr |
{#ptr-11}
Ptr
using Ptr = std::shared_ptr< ClientConnection >
Defined in src/http/include/icy/http/client.h:36
Private Methods
| Return | Name | Description |
|---|---|---|
void | onHeaders virtual override | Connection interface. |
void | onPayload virtual override | Called for each chunk of incoming response body data. |
void | onComplete virtual override | Called when the full HTTP response has been received. |
void | onClose virtual override | Called when the connection is closed. |
bool | onSocketError virtual override | Called 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
| Name | Kind | Owner |
|---|---|---|
data | variable | Declared here |
flags | variable | Declared here |
Public Attributes
| Return | Name | Description |
|---|---|---|
Buffer | data | |
int | flags |
{#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:
SocketAdapterSubclassed by:ClientConnection,ServerConnection
Base HTTP connection managing socket I/O and message lifecycle
List of all members
| Name | Kind | Owner |
|---|---|---|
ConnectionStream | friend | Declared here |
ConnectionAdapter | friend | Declared here |
Connection | function | Declared here |
onHeaders | function | Declared here |
onPayload | function | Declared here |
onComplete | function | Declared here |
onClose | function | Declared here |
send | function | Declared here |
sendOwned | function | Declared here |
sendHeader | function | Declared here |
close | function | Declared here |
markActive | function | Declared here |
beginStreaming | function | Declared here |
endStreaming | function | Declared here |
closed | function | Declared here |
error | function | Declared here |
headerAutoSendEnabled | function | Declared here |
setHeaderAutoSendEnabled | function | Declared here |
replaceAdapter | function | Declared here |
replaceAdapter | function | Declared here |
secure | function | Declared here |
socket | function | Declared here |
adapter | function | Declared here |
request | function | Declared here |
response | function | Declared here |
incomingHeader | function | Declared here |
outgoingHeader | function | Declared here |
_socket | variable | Declared here |
_adapter | variable | Declared here |
_request | variable | Declared here |
_response | variable | Declared here |
_error | variable | Declared here |
_closed | variable | Declared here |
_shouldSendHeader | variable | Declared here |
setError | function | Declared here |
onSocketConnect | function | Declared here |
onSocketRecv | function | Declared here |
onSocketError | function | Declared here |
onSocketClose | function | Declared here |
Ptr | typedef | Declared here |
priority | variable | Inherited from SocketAdapter |
SocketAdapter | function | Inherited from SocketAdapter |
~SocketAdapter | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
setSender | function | Inherited from SocketAdapter |
sender | function | Inherited from SocketAdapter |
addReceiver | function | Inherited from SocketAdapter |
removeReceiver | function | Inherited from SocketAdapter |
hasReceiver | function | Inherited from SocketAdapter |
receivers | function | Inherited from SocketAdapter |
onSocketConnect | function | Inherited from SocketAdapter |
onSocketRecv | function | Inherited from SocketAdapter |
onSocketError | function | Inherited from SocketAdapter |
onSocketClose | function | Inherited from SocketAdapter |
_sender | variable | Inherited from SocketAdapter |
_receivers | variable | Inherited from SocketAdapter |
_dirty | variable | Inherited from SocketAdapter |
cleanupReceivers | function | Inherited from SocketAdapter |
Inherited from SocketAdapter
| Kind | Name | Description |
|---|---|---|
variable | priority | The priority of this adapter for STL sort operations. |
function | SocketAdapter | Creates the SocketAdapter. |
function | ~SocketAdapter virtual noexcept | Destroys the SocketAdapter. |
function | send virtual nodiscard | Sends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | send virtual nodiscard | |
function | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual nodiscard | |
function | sendPacket virtual | Sends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | sendPacket virtual | |
function | sendPacket virtual | Sends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed. |
function | setSender virtual | Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default. |
function | sender | Returns the output SocketAdapter pointer. |
function | addReceiver virtual | Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default. |
function | removeReceiver virtual | Remove the given receiver. |
function | hasReceiver virtual | Returns true if the given receiver is connected. |
function | receivers | Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list. |
function | onSocketConnect virtual | Called when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event. |
function | onSocketRecv virtual | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
variable | _sender | |
variable | _receivers | |
variable | _dirty | |
function | cleanupReceivers virtual |
Friends
| Name | Description |
|---|---|
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
| Return | Name | Description |
|---|---|---|
Connection | Creates a Connection using the given TCP socket. | |
void | onHeaders virtual | Called when the incoming HTTP headers have been fully parsed. |
void | onPayload virtual | Called for each chunk of incoming body data after headers are complete. |
void | onComplete virtual | Called when the incoming HTTP message is fully received. |
void | onClose virtual | Called when the connection is closed. |
ssize_t | send virtual override | Send raw data to the peer. |
ssize_t | sendOwned virtual override | Send an owned payload buffer to the peer. |
ssize_t | sendHeader virtual | Send the outdoing HTTP header. |
void | close virtual | Close the connection and schedule the object for deferred deletion. |
void | markActive virtual inline | Marks the connection as active. Server connections override this to refresh the idle timer. |
void | beginStreaming virtual inline | Explicitly enter long-lived streaming mode. Base connections ignore this; server connections use it to disable keep-alive idle reaping while a response stream is active. |
void | endStreaming virtual inline | Exit long-lived streaming mode. |
bool | closed const nodiscard | Return true if the connection is closed. |
icy::Error | error const nodiscard | Return the error object if any. |
bool | headerAutoSendEnabled const nodiscard | Return true if headers should be automatically sent. |
void | setHeaderAutoSendEnabled | Enable or disable automatic header emission for the next outgoing send path. |
void | replaceAdapter virtual | Assign the new ConnectionAdapter and setup the chain. The flow is: Connection <-> ConnectionAdapter <-> Socket. Takes ownership of the adapter (deferred deletion via uv loop). |
void | replaceAdapter virtual | Overload for nullptr (used in destructor to clear adapter). |
bool | secure const nodiscard | Return true if the connection uses TLS/SSL. |
net::TCPSocket::Ptr & | socket nodiscard | Return the underlying socket pointer. |
net::SocketAdapter * | adapter const nodiscard | Return the underlying adapter pointer. |
Request & | request nodiscard | The HTTP request headers. |
Response & | response nodiscard | The HTTP response headers. |
http::Message * | incomingHeader virtual | Returns the incoming HTTP message header (request or response depending on role). |
http::Message * | outgoingHeader virtual | Returns the outgoing HTTP message header (request or response depending on role). |
{#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
socketThe 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
bufferBuffer 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
| Return | Name | Description |
|---|---|---|
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
| Return | Name | Description |
|---|---|---|
void | setError virtual | Set the internal error. Note: Setting the error does not [close()](#close-20) the connection. |
bool | onSocketConnect virtual override | net::SocketAdapter interface |
bool | onSocketRecv virtual override | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
bool | onSocketError virtual override | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
bool | onSocketClose virtual override | Called 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
-
socketThe socket that received data. -
bufferThe received data buffer. -
peerAddressAddress 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
-
socketThe socket that encountered the error. -
errorError 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
socketThe socket that was closed.
Returns
true to stop propagation to subsequent receivers.
Reimplements
Public Types
| Name | Description |
|---|---|
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
| Name | Kind | Owner |
|---|---|---|
ConnectionAdapter | function | Declared here |
send | function | Declared here |
sendOwned | function | Declared here |
removeReceiver | function | Declared here |
parser | function | Declared here |
connection | function | Declared here |
reset | function | Declared here |
_connection | variable | Declared here |
_parser | variable | Declared here |
onSocketRecv | function | Declared here |
onParserHeader | function | Declared here |
onParserHeadersEnd | function | Declared here |
onParserChunk | function | Declared here |
onParserError | function | Declared here |
onParserEnd | function | Declared here |
onParserHeader | function | Inherited from ParserObserver |
onParserHeadersEnd | function | Inherited from ParserObserver |
onParserChunk | function | Inherited from ParserObserver |
onParserEnd | function | Inherited from ParserObserver |
onParserError | function | Inherited from ParserObserver |
priority | variable | Inherited from SocketAdapter |
SocketAdapter | function | Inherited from SocketAdapter |
~SocketAdapter | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
setSender | function | Inherited from SocketAdapter |
sender | function | Inherited from SocketAdapter |
addReceiver | function | Inherited from SocketAdapter |
removeReceiver | function | Inherited from SocketAdapter |
hasReceiver | function | Inherited from SocketAdapter |
receivers | function | Inherited from SocketAdapter |
onSocketConnect | function | Inherited from SocketAdapter |
onSocketRecv | function | Inherited from SocketAdapter |
onSocketError | function | Inherited from SocketAdapter |
onSocketClose | function | Inherited from SocketAdapter |
_sender | variable | Inherited from SocketAdapter |
_receivers | variable | Inherited from SocketAdapter |
_dirty | variable | Inherited from SocketAdapter |
cleanupReceivers | function | Inherited from SocketAdapter |
Inherited from ParserObserver
| Kind | Name | Description |
|---|---|---|
function | onParserHeader virtual | Called for each parsed HTTP header name/value pair. |
function | onParserHeadersEnd virtual | Called when all HTTP headers have been parsed. |
function | onParserChunk virtual | Called for each chunk of body data received. |
function | onParserEnd virtual | Called when the HTTP message is fully parsed. |
function | onParserError virtual | Called when a parse error occurs. |
Inherited from SocketAdapter
| Kind | Name | Description |
|---|---|---|
variable | priority | The priority of this adapter for STL sort operations. |
function | SocketAdapter | Creates the SocketAdapter. |
function | ~SocketAdapter virtual noexcept | Destroys the SocketAdapter. |
function | send virtual nodiscard | Sends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | send virtual nodiscard | |
function | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual nodiscard | |
function | sendPacket virtual | Sends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | sendPacket virtual | |
function | sendPacket virtual | Sends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed. |
function | setSender virtual | Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default. |
function | sender | Returns the output SocketAdapter pointer. |
function | addReceiver virtual | Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default. |
function | removeReceiver virtual | Remove the given receiver. |
function | hasReceiver virtual | Returns true if the given receiver is connected. |
function | receivers | Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list. |
function | onSocketConnect virtual | Called when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event. |
function | onSocketRecv virtual | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
variable | _sender | |
variable | _receivers | |
variable | _dirty | |
function | cleanupReceivers virtual |
Public Methods
| Return | Name | Description |
|---|---|---|
ConnectionAdapter | Creates a ConnectionAdapter for the given connection. | |
ssize_t | send virtual override | Sends data to the peer, flushing the outgoing HTTP header first if needed. |
ssize_t | sendOwned virtual override | Sends an owned payload buffer to the connected peer. |
void | removeReceiver override | Remove the given receiver. |
Parser & | parser nodiscard | Returns the HTTP parser instance. |
Connection * | connection nodiscard | Returns the owning Connection pointer, or nullptr if detached. |
void | reset | Resets the adapter for reuse with a new socket and request. Clears the parser state and re-wires the sender without reallocating. Used by the connection pool to avoid destroying/recreating adapters. |
{#connectionadapter-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
-
connectionOwning HTTP connection. -
typeParser 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
-
dataPointer to the data buffer. -
lenNumber of bytes to send. -
flagsSend flags (unused for HTTP, used for WebSocket frame type).
Returns
Number of bytes sent, or -1 on error.
Reimplements
{#sendowned-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
-
senderNew socket adapter to send data through. -
requestNew HTTP request object for the parser to populate.
Protected Attributes
| Return | Name | Description |
|---|---|---|
Connection * | _connection | |
Parser | _parser |
{#_connection}
_connection
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
| Return | Name | Description |
|---|---|---|
bool | onSocketRecv virtual override | SocketAdapter interface. |
void | onParserHeader virtual override | HTTP Parser interface. |
void | onParserHeadersEnd virtual override | Called when all HTTP headers have been parsed. |
void | onParserChunk virtual override | Called for each chunk of body data received. |
void | onParserError virtual override | Called when a parse error occurs. |
void | onParserEnd virtual override | Called when the HTTP message is fully parsed. |
{#onsocketrecv-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
upgradeTrue 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
-
dataPointer to the body data chunk. -
lenLength 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
errError 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
| Name | Kind | Owner |
|---|---|---|
acquire | function | Declared here |
release | function | Declared here |
setMaxSize | function | Declared here |
size | function | Declared here |
_pool | variable | Declared here |
_maxSize | variable | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
ServerConnection::Ptr | acquire inline | Takes a connection from the pool for reuse. |
bool | release inline | Returns a connection to the pool after use. |
void | setMaxSize inline | Sets the maximum number of connections the pool will hold. |
size_t | size const inline nodiscard | Returns 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
connThe 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
nMaximum 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
| Return | Name | Description |
|---|---|---|
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
| Name | Kind | Owner |
|---|---|---|
Outgoing | variable | Declared here |
Incoming | variable | Declared here |
IncomingProgress | variable | Declared here |
OutgoingProgress | variable | Declared here |
ConnectionStream | function | Declared here |
send | function | Declared here |
connection | function | Declared here |
_connection | variable | Declared here |
onSocketRecv | function | Declared here |
priority | variable | Inherited from SocketAdapter |
SocketAdapter | function | Inherited from SocketAdapter |
~SocketAdapter | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
setSender | function | Inherited from SocketAdapter |
sender | function | Inherited from SocketAdapter |
addReceiver | function | Inherited from SocketAdapter |
removeReceiver | function | Inherited from SocketAdapter |
hasReceiver | function | Inherited from SocketAdapter |
receivers | function | Inherited from SocketAdapter |
onSocketConnect | function | Inherited from SocketAdapter |
onSocketRecv | function | Inherited from SocketAdapter |
onSocketError | function | Inherited from SocketAdapter |
onSocketClose | function | Inherited from SocketAdapter |
_sender | variable | Inherited from SocketAdapter |
_receivers | variable | Inherited from SocketAdapter |
_dirty | variable | Inherited from SocketAdapter |
cleanupReceivers | function | Inherited from SocketAdapter |
Inherited from SocketAdapter
| Kind | Name | Description |
|---|---|---|
variable | priority | The priority of this adapter for STL sort operations. |
function | SocketAdapter | Creates the SocketAdapter. |
function | ~SocketAdapter virtual noexcept | Destroys the SocketAdapter. |
function | send virtual nodiscard | Sends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | send virtual nodiscard | |
function | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual nodiscard | |
function | sendPacket virtual | Sends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | sendPacket virtual | |
function | sendPacket virtual | Sends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed. |
function | setSender virtual | Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default. |
function | sender | Returns the output SocketAdapter pointer. |
function | addReceiver virtual | Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default. |
function | removeReceiver virtual | Remove the given receiver. |
function | hasReceiver virtual | Returns true if the given receiver is connected. |
function | receivers | Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list. |
function | onSocketConnect virtual | Called when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event. |
function | onSocketRecv virtual | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
variable | _sender | |
variable | _receivers | |
variable | _dirty | |
function | cleanupReceivers virtual |
Public Attributes
| Return | Name | Description |
|---|---|---|
PacketStream | Outgoing | The Outgoing stream is responsible for packetizing raw application data into the agreed upon HTTP format and sending it to the peer. |
PacketStream | Incoming | The Incoming stream emits incoming HTTP packets for processing by the application. |
ProgressSignal | IncomingProgress | Fired on download progress. |
ProgressSignal | OutgoingProgress | Fired 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
| Return | Name | Description |
|---|---|---|
ConnectionStream | 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. | |
ssize_t | send virtual override | Send data via the Outgoing stream. |
Connection::Ptr | connection nodiscard | Return 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
connectionThe 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
| Return | Name | Description |
|---|---|---|
Connection::Ptr | _connection |
{#_connection-1}
_connection
Connection::Ptr _connection
Defined in src/http/include/icy/http/connection.h:294
Protected Methods
| Return | Name | Description |
|---|---|---|
bool | onSocketRecv virtual override | Called 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
-
socketThe socket that received data. -
bufferThe received data buffer. -
peerAddressAddress of the sender.
Returns
true to stop propagation to subsequent receivers.
Reimplements
{#cookie}
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
| Name | Kind | Owner |
|---|---|---|
Cookie | function | Declared here |
Cookie | function | Declared here |
Cookie | function | Declared here |
Cookie | function | Declared here |
Cookie | function | Declared here |
~Cookie | function | Declared here |
operator= | function | Declared here |
setVersion | function | Declared here |
getVersion | function | Declared here |
setName | function | Declared here |
getName | function | Declared here |
setValue | function | Declared here |
getValue | function | Declared here |
setComment | function | Declared here |
getComment | function | Declared here |
setDomain | function | Declared here |
getDomain | function | Declared here |
setPath | function | Declared here |
getPath | function | Declared here |
setSecure | function | Declared here |
getSecure | function | Declared here |
setMaxAge | function | Declared here |
getMaxAge | function | Declared here |
setHttpOnly | function | Declared here |
getHttpOnly | function | Declared here |
toString | function | Declared here |
escape | function | Declared here |
unescape | function | Declared here |
_version | variable | Declared here |
_name | variable | Declared here |
_value | variable | Declared here |
_comment | variable | Declared here |
_domain | variable | Declared here |
_path | variable | Declared here |
_secure | variable | Declared here |
_maxAge | variable | Declared here |
_httpOnly | variable | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
Cookie | Creates an empty Cookie. | |
Cookie explicit | Creates a cookie with the given name. The cookie never expires. | |
Cookie explicit | Creates a cookie from the given NVCollection. | |
Cookie | Creates a cookie with the given name and value. The cookie never expires. | |
Cookie | Creates the Cookie by copying another one. | |
~Cookie | Destroys the Cookie. | |
Cookie & | operator= | Assigns a cookie. |
void | setVersion | Sets the version of the cookie. |
int | getVersion const inline nodiscard | Returns the version of the cookie, which is either 0 or 1. |
void | setName | Sets the name of the cookie. |
const std::string & | getName const inline nodiscard | Returns the name of the cookie. |
void | setValue | Sets the value of the cookie. |
const std::string & | getValue const inline nodiscard | Returns the value of the cookie. |
void | setComment | Sets the comment for the cookie. |
const std::string & | getComment const inline nodiscard | Returns the comment for the cookie. |
void | setDomain | Sets the domain for the cookie. |
const std::string & | getDomain const inline nodiscard | Returns the domain for the cookie. |
void | setPath | Sets the path for the cookie. |
const std::string & | getPath const inline nodiscard | Returns the path for the cookie. |
void | setSecure | Sets the value of the secure flag for the cookie. |
bool | getSecure const inline nodiscard | Returns the value of the secure flag for the cookie. |
void | setMaxAge | Sets the maximum age in seconds for the cookie. |
int | getMaxAge const inline nodiscard | Returns the maximum age in seconds for the cookie. |
void | setHttpOnly | Sets the HttpOnly flag for the cookie. |
bool | getHttpOnly const inline nodiscard | Returns true if the cookie's HttpOnly flag is set. |
std::string | toString const nodiscard | Returns a std::string representation of the cookie, suitable for use in a Set-Cookie header. |
{#cookie-1}
Cookie
Cookie()
Defined in src/http/include/icy/http/cookie.h:43
Creates an empty Cookie.
{#cookie-2}
Cookie
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}
Cookie
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
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
Cookie(const Cookie & cookie)
Defined in src/http/include/icy/http/cookie.h:61
Creates the Cookie by copying another one.
{#cookie-6}
~Cookie
~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
| Return | Name | Description |
|---|---|---|
std::string | escape static | 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. |
std::string | unescape static | Unescapes 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
| Return | Name | Description |
|---|---|---|
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
| Name | Kind | Owner |
|---|---|---|
FilePart | function | Declared here |
FilePart | function | Declared here |
FilePart | function | Declared here |
~FilePart | function | Declared here |
open | function | Declared here |
reset | function | Declared here |
writeChunk | function | Declared here |
write | function | Declared here |
write | function | Declared here |
filename | function | Declared here |
stream | function | Declared here |
length | function | Declared here |
_path | variable | Declared here |
_filename | variable | Declared here |
_istr | variable | Declared here |
_fileSize | variable | Declared here |
FormPart | function | Inherited from FormPart |
~FormPart | function | Inherited from FormPart |
reset | function | Inherited from FormPart |
writeChunk | function | Inherited from FormPart |
write | function | Inherited from FormPart |
write | function | Inherited from FormPart |
headers | function | Inherited from FormPart |
initialWrite | function | Inherited from FormPart |
contentType | function | Inherited from FormPart |
length | function | Inherited from FormPart |
_contentType | variable | Inherited from FormPart |
_length | variable | Inherited from FormPart |
_headers | variable | Inherited from FormPart |
_initialWrite | variable | Inherited from FormPart |
Inherited from FormPart
| Kind | Name | Description |
|---|---|---|
function | FormPart | Creates the FormPart with the given MIME content type. |
function | ~FormPart virtual | Destroys the FormPart. |
function | reset virtual | Resets the internal state and write position to the beginning. Called by FormWriter when retrying or recalculating content length. |
function | writeChunk virtual | Writes the next chunk of data to the FormWriter. |
function | write virtual | Writes the entire part data to the FormWriter in one call. |
function | write virtual | Writes the entire part data to an output stream (used for content-length calculation). |
function | headers nodiscard | Returns the extra MIME headers for this part (e.g. Content-Disposition). |
function | initialWrite virtual const nodiscard | Returns true if this is the first write call since construction or reset(). |
function | contentType const nodiscard | Returns the MIME content type for this part. |
function | length virtual const nodiscard | Returns the total byte length of the part data. |
variable | _contentType | |
variable | _length | |
variable | _headers | |
variable | _initialWrite |
Public Methods
| Return | Name | Description |
|---|---|---|
FilePart | Creates the FilePart for the given path. | |
FilePart | Creates the FilePart for the given path and MIME type. | |
FilePart | Creates the FilePart for the given path and MIME type. The given filename is used as part filename (see filename()) only. | |
~FilePart virtual | Destroys the FilePart. | |
void | open virtual | Opens the file for reading. |
void | reset virtual override | Resets the file stream to the beginning and clears initial-write state. |
bool | writeChunk virtual override | Writes the next chunk of the file to the FormWriter. |
void | write virtual override | Writes the entire file content to the FormWriter. |
void | write virtual override | Writes the entire file content to an output stream (used for content-length calculation). |
const std::string & | filename const nodiscard | Returns the filename component of the file path (not the full path). |
std::ifstream & | stream nodiscard | Returns a reference to the underlying file input stream. |
uint64_t | length virtual const nodiscard override | Returns 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_errorif 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
writerThe 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
writerThe FormWriter to send data through.
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
ostrOutput 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
| Return | Name | Description |
|---|---|---|
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
| Name | Kind | Owner |
|---|---|---|
FormPart | function | Declared here |
~FormPart | function | Declared here |
reset | function | Declared here |
writeChunk | function | Declared here |
write | function | Declared here |
write | function | Declared here |
headers | function | Declared here |
initialWrite | function | Declared here |
contentType | function | Declared here |
length | function | Declared here |
_contentType | variable | Declared here |
_length | variable | Declared here |
_headers | variable | Declared here |
_initialWrite | variable | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
FormPart | Creates the FormPart with the given MIME content type. | |
~FormPart virtual | Destroys the FormPart. | |
void | reset virtual | Resets the internal state and write position to the beginning. Called by FormWriter when retrying or recalculating content length. |
bool | writeChunk virtual | Writes the next chunk of data to the FormWriter. |
void | write virtual | Writes the entire part data to the FormWriter in one call. |
void | write virtual | Writes the entire part data to an output stream (used for content-length calculation). |
NVCollection & | headers nodiscard | Returns the extra MIME headers for this part (e.g. Content-Disposition). |
bool | initialWrite virtual const nodiscard | Returns true if this is the first write call since construction or reset(). |
const std::string & | contentType const nodiscard | Returns the MIME content type for this part. |
uint64_t | length virtual const nodiscard | Returns 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
contentTypeMIME 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
writerThe 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
writerThe FormWriter to send data through.
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
ostrOutput 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
| Return | Name | Description |
|---|---|---|
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
| Name | Kind | Owner |
|---|---|---|
FormPart | friend | Declared here |
FilePart | friend | Declared here |
StringPart | friend | Declared here |
emitter | variable | Declared here |
~FormWriter | function | Declared here |
addPart | function | Declared here |
start | function | Declared here |
stop | function | Declared here |
complete | function | Declared here |
cancelled | function | Declared here |
prepareSubmit | function | Declared here |
calculateMultipartContentLength | function | Declared here |
writeUrl | function | Declared here |
writeMultipartChunk | function | Declared here |
writeAsync | function | Declared here |
setEncoding | function | Declared here |
encoding | function | Declared here |
setBoundary | function | Declared here |
boundary | function | Declared here |
connection | function | Declared here |
ENCODING_URL | variable | Declared here |
ENCODING_MULTIPART_FORM | variable | Declared here |
ENCODING_MULTIPART_RELATED | variable | Declared here |
create | function | Declared here |
_stream | variable | Declared here |
_runner | variable | Declared here |
_encoding | variable | Declared here |
_boundary | variable | Declared here |
_parts | variable | Declared here |
_filesLength | variable | Declared here |
_writeState | variable | Declared here |
_initial | variable | Declared here |
_complete | variable | Declared here |
FormWriter | function | Declared here |
FormWriter | function | Declared here |
FormWriter | function | Declared here |
writePartHeader | function | Declared here |
writeEnd | function | Declared here |
updateProgress | function | Declared here |
Map | typedef | Inherited from NVCollection |
Iterator | typedef | Inherited from NVCollection |
ConstIterator | typedef | Inherited from NVCollection |
_map | variable | Inherited from NVCollection |
NVCollection | function | Inherited from NVCollection |
NVCollection | function | Inherited from NVCollection |
NVCollection | function | Inherited from NVCollection |
~NVCollection | function | Inherited from NVCollection |
operator= | function | Inherited from NVCollection |
operator= | function | Inherited from NVCollection |
operator[] | function | Inherited from NVCollection |
set | function | Inherited from NVCollection |
add | function | Inherited from NVCollection |
add | function | Inherited from NVCollection |
get | function | Inherited from NVCollection |
get | function | Inherited from NVCollection |
has | function | Inherited from NVCollection |
find | function | Inherited from NVCollection |
begin | function | Inherited from NVCollection |
end | function | Inherited from NVCollection |
empty | function | Inherited from NVCollection |
size | function | Inherited from NVCollection |
erase | function | Inherited from NVCollection |
clear | function | Inherited from NVCollection |
_emitter | variable | Inherited from PacketStreamAdapter |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
~PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
getEmitter | function | Inherited from PacketStreamAdapter |
retention | function | Inherited from PacketStreamAdapter |
onStreamStateChange | function | Inherited from PacketStreamAdapter |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
operator= | function | Inherited from PacketStreamAdapter |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
operator= | function | Inherited from PacketStreamAdapter |
start | function | Inherited from Startable |
stop | function | Inherited from Startable |
Inherited from NVCollection
| Kind | Name | Description |
|---|---|---|
typedef | Map | |
typedef | Iterator | |
typedef | ConstIterator | |
variable | _map | |
function | NVCollection inline | |
function | NVCollection inline | |
function | NVCollection inline noexcept | |
function | ~NVCollection virtual inline | |
function | operator= | Assigns the name-value pairs of another NVCollection to this one. |
function | operator= noexcept | |
function | operator[] const | Returns the value of the (first) name-value pair with the given name. |
function | set | Sets the value of the (first) name-value pair with the given name. |
function | add | Adds a new name-value pair with the given name and value. |
function | add | Adds a new name-value pair using move semantics. |
function | get const | Returns the value of the first name-value pair with the given name. |
function | get const | Returns 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. |
function | has const | Returns true if there is at least one name-value pair with the given name. |
function | find const | Returns an iterator pointing to the first name-value pair with the given name. |
function | begin const | Returns an iterator pointing to the begin of the name-value pair collection. |
function | end const | Returns an iterator pointing to the end of the name-value pair collection. |
function | empty const | Returns true iff the header does not have any content. |
function | size const | Returns the number of name-value pairs in the collection. |
function | erase | Removes all name-value pairs with the given name. |
function | clear | Removes all name-value pairs and their values. |
Inherited from PacketStreamAdapter
| Kind | Name | Description |
|---|---|---|
variable | _emitter | |
function | PacketStreamAdapter | Construct the adapter, binding it to the given packet signal. |
function | ~PacketStreamAdapter virtual inline | |
function | emit virtual | Emit a mutable raw buffer as a packet. |
function | emit virtual | Emit a read-only raw buffer as a packet (data is copied internally). |
function | emit virtual | Emit a string as a packet (data is copied internally). |
function | emit virtual | Emit a flag-only packet carrying no payload data. |
function | emit virtual | Emit an existing packet directly onto the outgoing signal. |
function | getEmitter | Returns a reference to the outgoing packet signal. |
function | retention virtual const nodiscard | Returns 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. |
function | onStreamStateChange virtual inline | Called 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. |
function | PacketStreamAdapter | NonCopyable and NonMovable. |
function | operator= | Deleted assignment operator. |
function | PacketStreamAdapter | Deleted constructor. |
function | operator= | Deleted assignment operator. |
Inherited from Startable
| Kind | Name | Description |
|---|---|---|
function | start virtual | Starts the object (e.g. begins processing or listening). |
function | stop virtual | Stops the object (e.g. halts processing or closes resources). |
Friends
| Name | Description |
|---|---|
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
| Return | Name | Description |
|---|---|---|
PacketSignal | emitter | The outgoing packet emitter. |
{#emitter-6}
emitter
PacketSignal emitter
Defined in src/http/include/icy/http/form.h:122
The outgoing packet emitter.
Public Methods
| Return | Name | Description |
|---|---|---|
~FormWriter virtual | Destroys the FormWriter. | |
void | addPart | Adds a part or file attachment to the multipart form. |
void | start virtual | Starts the sending thread. |
void | stop virtual | Stops the sending thread. |
bool | complete const nodiscard | Returns true if the request is complete. |
bool | cancelled const nodiscard | Returns true if the request is cancelled. |
void | prepareSubmit | Prepares the outgoing HTTP request object for submitting the form. |
uint64_t | calculateMultipartContentLength | Processes the entire form body and computes its total byte length. Only meaningful for multipart/form-data when not using chunked encoding. |
void | writeUrl | 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 '&'. |
void | writeMultipartChunk | 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. |
void | writeAsync | Writes the next message chunk from the background runner thread. Called by the Runner; do not call directly. |
void | setEncoding | Sets the MIME encoding used for submitting the form. Must be set before prepareSubmit() is called. |
const std::string & | encoding const nodiscard | Returns the encoding used for posting the form. |
void | setBoundary | 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. |
const std::string & | boundary const nodiscard | Returns the MIME boundary used for writing multipart form data. |
ConnectionStream & | connection nodiscard | The 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
-
nameForm field name for this part. -
partPart 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
ostrOutput 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
encodingMIME 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
boundaryBoundary 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
| Return | Name | Description |
|---|---|---|
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}
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
| Return | Name | Description |
|---|---|---|
FormWriter * | create static | Creates 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
-
connThe HTTP connection stream to write form data to. -
encodingMIME encoding type.
Returns
Heap-allocated FormWriter. The caller owns the returned pointer.
Protected Attributes
| Return | Name | Description |
|---|---|---|
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
| Return | Name | Description |
|---|---|---|
FormWriter | Creates the FormWriter that uses the given encoding. | |
FormWriter | Deleted constructor. | |
FormWriter | Deleted constructor. | |
void | writePartHeader | Writes the message boundary std::string, followed by the message header to the output stream. |
void | writeEnd | Writes the final boundary std::string to the output stream. |
void | updateProgress virtual | Updates 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
| Name | Kind | Owner |
|---|---|---|
name | variable | Declared here |
part | variable | Declared here |
Public Attributes
| Return | Name | Description |
|---|---|---|
std::string | name | |
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:
NVCollectionSubclassed 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
| Name | Kind | Owner |
|---|---|---|
setVersion | function | Declared here |
getVersion | function | Declared here |
setContentLength | function | Declared here |
getContentLength | function | Declared here |
hasContentLength | function | Declared here |
setTransferEncoding | function | Declared here |
getTransferEncoding | function | Declared here |
setChunkedTransferEncoding | function | Declared here |
isChunkedTransferEncoding | function | Declared here |
setContentType | function | Declared here |
getContentType | function | Declared here |
setKeepAlive | function | Declared here |
getKeepAlive | function | Declared here |
write | function | Declared here |
write | function | Declared here |
write | function | Declared here |
HTTP_1_0 | variable | Declared here |
HTTP_1_1 | variable | Declared here |
IDENTITY_TRANSFER_ENCODING | variable | Declared here |
CHUNKED_TRANSFER_ENCODING | variable | Declared here |
UNKNOWN_CONTENT_LENGTH | variable | Declared here |
UNKNOWN_CONTENT_TYPE | variable | Declared here |
CONTENT_LENGTH | variable | Declared here |
CONTENT_TYPE | variable | Declared here |
TRANSFER_ENCODING | variable | Declared here |
CONNECTION | variable | Declared here |
CONNECTION_KEEP_ALIVE | variable | Declared here |
CONNECTION_CLOSE | variable | Declared here |
EMPTY | variable | Declared here |
_version | variable | Declared here |
Message | function | Declared here |
Message | function | Declared here |
~Message | function | Declared here |
Map | typedef | Inherited from NVCollection |
Iterator | typedef | Inherited from NVCollection |
ConstIterator | typedef | Inherited from NVCollection |
_map | variable | Inherited from NVCollection |
NVCollection | function | Inherited from NVCollection |
NVCollection | function | Inherited from NVCollection |
NVCollection | function | Inherited from NVCollection |
~NVCollection | function | Inherited from NVCollection |
operator= | function | Inherited from NVCollection |
operator= | function | Inherited from NVCollection |
operator[] | function | Inherited from NVCollection |
set | function | Inherited from NVCollection |
add | function | Inherited from NVCollection |
add | function | Inherited from NVCollection |
get | function | Inherited from NVCollection |
get | function | Inherited from NVCollection |
has | function | Inherited from NVCollection |
find | function | Inherited from NVCollection |
begin | function | Inherited from NVCollection |
end | function | Inherited from NVCollection |
empty | function | Inherited from NVCollection |
size | function | Inherited from NVCollection |
erase | function | Inherited from NVCollection |
clear | function | Inherited from NVCollection |
Inherited from NVCollection
| Kind | Name | Description |
|---|---|---|
typedef | Map | |
typedef | Iterator | |
typedef | ConstIterator | |
variable | _map | |
function | NVCollection inline | |
function | NVCollection inline | |
function | NVCollection inline noexcept | |
function | ~NVCollection virtual inline | |
function | operator= | Assigns the name-value pairs of another NVCollection to this one. |
function | operator= noexcept | |
function | operator[] const | Returns the value of the (first) name-value pair with the given name. |
function | set | Sets the value of the (first) name-value pair with the given name. |
function | add | Adds a new name-value pair with the given name and value. |
function | add | Adds a new name-value pair using move semantics. |
function | get const | Returns the value of the first name-value pair with the given name. |
function | get const | Returns 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. |
function | has const | Returns true if there is at least one name-value pair with the given name. |
function | find const | Returns an iterator pointing to the first name-value pair with the given name. |
function | begin const | Returns an iterator pointing to the begin of the name-value pair collection. |
function | end const | Returns an iterator pointing to the end of the name-value pair collection. |
function | empty const | Returns true iff the header does not have any content. |
function | size const | Returns the number of name-value pairs in the collection. |
function | erase | Removes all name-value pairs with the given name. |
function | clear | Removes all name-value pairs and their values. |
Public Methods
| Return | Name | Description |
|---|---|---|
void | setVersion | Sets the HTTP version for this message. |
const std::string & | getVersion const nodiscard | Returns the HTTP version for this message. |
void | setContentLength | Sets the Content-Length header. |
uint64_t | getContentLength const nodiscard | Returns the content length for this message, which may be UNKNOWN_CONTENT_LENGTH if no Content-Length header is present. |
bool | hasContentLength const nodiscard | Returns true if a Content-Length header is present. |
void | setTransferEncoding | Sets the transfer encoding for this message. |
const std::string & | getTransferEncoding const nodiscard | Returns the transfer encoding used for this message. |
void | setChunkedTransferEncoding | If flag is true, sets the Transfer-Encoding header to chunked. Otherwise, removes the Transfer-Encoding header. |
bool | isChunkedTransferEncoding const nodiscard | Returns true if the Transfer-Encoding header is set and its value is chunked. |
void | setContentType | Sets the content type for this message. |
const std::string & | getContentType const nodiscard | Returns the content type for this message. |
void | setKeepAlive | Sets the value of the Connection header field. |
bool | getKeepAlive const nodiscard | Returns true if |
void | write virtual const | Writes the message header to the given output stream. |
void | write virtual const | Writes the message header to the given output string. |
void | write virtual const | Writes 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
| Return | Name | Description |
|---|---|---|
const std::string | HTTP_1_0 static | |
const std::string | HTTP_1_1 static | |
const std::string | IDENTITY_TRANSFER_ENCODING static | |
const std::string | CHUNKED_TRANSFER_ENCODING static | |
const int | UNKNOWN_CONTENT_LENGTH static | |
const std::string | UNKNOWN_CONTENT_TYPE static | |
const std::string | CONTENT_LENGTH static | |
const std::string | CONTENT_TYPE static | |
const std::string | TRANSFER_ENCODING static | |
const std::string | CONNECTION static | |
const std::string | CONNECTION_KEEP_ALIVE static | |
const std::string | CONNECTION_CLOSE static | |
const std::string | EMPTY 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
| Return | Name | Description |
|---|---|---|
std::string | _version |
{#_version-1}
_version
std::string _version
Defined in src/http/include/icy/http/message.h:130
Protected Methods
| Return | Name | Description |
|---|---|---|
Message | Creates the Message with version HTTP/1.0. | |
Message | Creates the Message and sets the version. | |
~Message virtual | Destroys 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
| Name | Kind | Owner |
|---|---|---|
connection | variable | Declared here |
contentType | variable | Declared here |
isBase64 | variable | Declared here |
initial | variable | Declared here |
emitter | variable | Declared here |
MultipartAdapter | function | Declared here |
MultipartAdapter | function | Declared here |
emitHeader | function | Declared here |
emitChunkHeader | function | Declared here |
process | function | Declared here |
PacketProcessor | function | Inherited from PacketProcessor |
process | function | Inherited from PacketProcessor |
accepts | function | Inherited from PacketProcessor |
operator<< | function | Inherited from PacketProcessor |
_emitter | variable | Inherited from PacketStreamAdapter |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
~PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
getEmitter | function | Inherited from PacketStreamAdapter |
retention | function | Inherited from PacketStreamAdapter |
onStreamStateChange | function | Inherited from PacketStreamAdapter |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
operator= | function | Inherited from PacketStreamAdapter |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
operator= | function | Inherited from PacketStreamAdapter |
Inherited from PacketProcessor
| Kind | Name | Description |
|---|---|---|
function | PacketProcessor inline | |
function | process virtual | This method performs processing on the given packet and emits the result. |
function | accepts virtual inline | This method ensures compatibility with the given packet type. Return false to reject the packet. |
function | operator<< virtual inline | Stream operator alias for process(). |
Inherited from PacketStreamAdapter
| Kind | Name | Description |
|---|---|---|
variable | _emitter | |
function | PacketStreamAdapter | Construct the adapter, binding it to the given packet signal. |
function | ~PacketStreamAdapter virtual inline | |
function | emit virtual | Emit a mutable raw buffer as a packet. |
function | emit virtual | Emit a read-only raw buffer as a packet (data is copied internally). |
function | emit virtual | Emit a string as a packet (data is copied internally). |
function | emit virtual | Emit a flag-only packet carrying no payload data. |
function | emit virtual | Emit an existing packet directly onto the outgoing signal. |
function | getEmitter | Returns a reference to the outgoing packet signal. |
function | retention virtual const nodiscard | Returns 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. |
function | onStreamStateChange virtual inline | Called 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. |
function | PacketStreamAdapter | NonCopyable and NonMovable. |
function | operator= | Deleted assignment operator. |
function | PacketStreamAdapter | Deleted constructor. |
function | operator= | Deleted assignment operator. |
Public Attributes
| Return | Name | Description |
|---|---|---|
Connection::Ptr | connection | HTTP connection for sending the initial response header. |
std::string | contentType | Content-Type of each part (e.g. "image/jpeg"). |
bool | isBase64 | If true, adds "Content-Transfer-Encoding: base64" to each part. |
bool | initial | True until the first chunk is processed and the boundary header emitted. |
PacketSignal | emitter |
{#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
| Return | Name | Description |
|---|---|---|
MultipartAdapter inline | Creates a MultipartAdapter that sends headers through the given connection. The per-part content type is read from the connection's outgoing header. | |
MultipartAdapter inline | Creates a MultipartAdapter that emits its own raw HTTP/1.1 200 response header. Use this when no Connection object is available. | |
void | emitHeader virtual inline | 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. |
void | emitChunkHeader virtual inline | Emits the MIME boundary and per-part headers (Content-Type, optionally Content-Transfer-Encoding) for the next multipart chunk. |
void | process virtual inline | Wraps 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
-
connectionHTTP connection to use for sending the initial multipart header. -
base64If 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
-
contentTypeContent-Type for each multipart part. -
base64If 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
packetPacket 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
| Name | Kind | Owner |
|---|---|---|
Parser | function | Declared here |
Parser | function | Declared here |
Parser | function | Declared here |
Parser | function | Declared here |
Parser | function | Declared here |
parse | function | Declared here |
reset | function | Declared here |
resetState | function | Declared here |
complete | function | Declared here |
upgrade | function | Declared here |
type | function | Declared here |
setRequest | function | Declared here |
setResponse | function | Declared here |
setObserver | function | Declared here |
clearMessage | function | Declared here |
message | function | Declared here |
observer | function | Declared here |
_observer | variable | Declared here |
_request | variable | Declared here |
_response | variable | Declared here |
_message | variable | Declared here |
_parser | variable | Declared here |
_settings | variable | Declared here |
_type | variable | Declared here |
_wasHeaderValue | variable | Declared here |
_lastHeaderField | variable | Declared here |
_lastHeaderValue | variable | Declared here |
_complete | variable | Declared here |
_upgrade | variable | Declared here |
_error | variable | Declared here |
_lastResult | variable | Declared here |
_scratch | variable | Declared here |
init | function | Declared here |
clearBoundMessage | function | Declared here |
storeHeader | function | Declared here |
applyScratchToBoundMessage | function | Declared here |
onHeader | function | Declared here |
onHeadersEnd | function | Declared here |
onBody | function | Declared here |
onMessageEnd | function | Declared here |
onError | function | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
Parser | Creates a response parser. The response object is populated as data is parsed. | |
Parser | Creates a request parser. The request object is populated as data is parsed. | |
Parser | Creates a parser of the given type without binding a message object. | |
Parser | Deleted constructor. | |
Parser | Deleted constructor. | |
ParseResult | parse | Feeds a buffer of raw HTTP data into the parser. |
void | reset | Reset the internal state (reinitialises llhttp). Safe to call externally, NOT from inside llhttp callbacks. |
void | resetState | Reset internal flags without reinitialising llhttp. Safe to call from inside llhttp callbacks (e.g. on_message_begin). |
bool | complete const nodiscard | Returns true if parsing is complete, either in success or error. |
bool | upgrade const nodiscard | Returns true if the connection should be upgraded. |
llhttp_type_t | type const inline nodiscard | Returns the parser type (HTTP_REQUEST or HTTP_RESPONSE). |
void | setRequest | Binds an HTTP request object to populate during parsing. Must only be called when no message is currently set and type is HTTP_REQUEST. |
void | setResponse | Binds an HTTP response object to populate during parsing. Must only be called when no message is currently set and type is HTTP_RESPONSE. |
void | setObserver | Sets the observer that receives parser events. |
void | clearMessage | Clear request/response pointers so they can be re-set. Used when resetting a pooled connection for reuse. |
http::Message * | message nodiscard | Returns the currently bound message (request or response), or nullptr. |
ParserObserver * | observer const nodiscard | Returns 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
responseHTTP 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
requestHTTP 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
typeEither 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
-
dataPointer to the input data buffer. -
lengthNumber 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
requestThe 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
responseThe 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
observerObserver 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
| Return | Name | Description |
|---|---|---|
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
| Return | Name | Description |
|---|---|---|
void | init | |
void | clearBoundMessage | |
void | storeHeader | |
void | applyScratchToBoundMessage | |
void | onHeader | Callbacks. |
void | onHeadersEnd | |
void | onBody | |
void | onMessageEnd | |
void | onError |
{#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
| Name | Kind | Owner |
|---|---|---|
bytesConsumed | variable | Declared here |
messageComplete | variable | Declared here |
upgrade | variable | Declared here |
error | variable | Declared here |
ok | function | Declared here |
Public Attributes
| Return | Name | Description |
|---|---|---|
size_t | bytesConsumed | |
bool | messageComplete | |
bool | upgrade | |
Error | error |
{#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
| Return | Name | Description |
|---|---|---|
bool | ok 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
| Name | Kind | Owner |
|---|---|---|
version | variable | Declared here |
method | variable | Declared here |
uri | variable | Declared here |
reason | variable | Declared here |
status | variable | Declared here |
headers | variable | Declared here |
reset | function | Declared here |
Public Attributes
| Return | Name | Description |
|---|---|---|
std::string | version | |
std::string | method | |
std::string | uri | |
std::string | reason | |
http::StatusCode | status | |
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
| Return | Name | Description |
|---|---|---|
void | reset 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
| Name | Kind | Owner |
|---|---|---|
onParserHeader | function | Declared here |
onParserHeadersEnd | function | Declared here |
onParserChunk | function | Declared here |
onParserEnd | function | Declared here |
onParserError | function | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
void | onParserHeader virtual | Called for each parsed HTTP header name/value pair. |
void | onParserHeadersEnd virtual | Called when all HTTP headers have been parsed. |
void | onParserChunk virtual | Called for each chunk of body data received. |
void | onParserEnd virtual | Called when the HTTP message is fully parsed. |
void | onParserError virtual | Called 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
-
nameHeader field name. -
valueHeader 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
upgradeTrue 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
-
dataPointer to the body data chunk. -
lenLength 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
errError 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
| Name | Kind | Owner |
|---|---|---|
sender | variable | Declared here |
current | variable | Declared here |
total | variable | Declared here |
ProgressSignal | function | Declared here |
progress | function | Declared here |
update | function | Declared here |
Public Attributes
| Return | Name | Description |
|---|---|---|
void * | sender | Optional context pointer identifying the sender. |
uint64_t | current | Bytes transferred so far. |
uint64_t | total | Total 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
| Return | Name | Description |
|---|---|---|
ProgressSignal inline | ||
double | progress const inline nodiscard | Returns the current transfer progress as a percentage (0-100). |
void | update inline | Advances 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
nreadNumber of bytes just transferred.
Exceptions
std::runtime_errorif 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
| Name | Kind | Owner |
|---|---|---|
operator<< | friend | Declared here |
Request | function | Declared here |
Request | function | Declared here |
Request | function | Declared here |
Request | function | Declared here |
~Request | function | Declared here |
setMethod | function | Declared here |
getMethod | function | Declared here |
setURI | function | Declared here |
appendURI | function | Declared here |
getURI | function | Declared here |
setHost | function | Declared here |
setHost | function | Declared here |
getHost | function | Declared here |
setCookies | function | Declared here |
getCookies | function | Declared here |
getURIParameters | function | Declared here |
hasCredentials | function | Declared here |
getCredentials | function | Declared here |
setCredentials | function | Declared here |
hasProxyCredentials | function | Declared here |
getProxyCredentials | function | Declared here |
setProxyCredentials | function | Declared here |
write | function | Declared here |
write | function | Declared here |
write | function | Declared here |
getCredentials | function | Declared here |
setCredentials | function | Declared here |
_method | variable | Declared here |
_uri | variable | Declared here |
setVersion | function | Inherited from Message |
getVersion | function | Inherited from Message |
setContentLength | function | Inherited from Message |
getContentLength | function | Inherited from Message |
hasContentLength | function | Inherited from Message |
setTransferEncoding | function | Inherited from Message |
getTransferEncoding | function | Inherited from Message |
setChunkedTransferEncoding | function | Inherited from Message |
isChunkedTransferEncoding | function | Inherited from Message |
setContentType | function | Inherited from Message |
getContentType | function | Inherited from Message |
setKeepAlive | function | Inherited from Message |
getKeepAlive | function | Inherited from Message |
write | function | Inherited from Message |
write | function | Inherited from Message |
write | function | Inherited from Message |
HTTP_1_0 | variable | Inherited from Message |
HTTP_1_1 | variable | Inherited from Message |
IDENTITY_TRANSFER_ENCODING | variable | Inherited from Message |
CHUNKED_TRANSFER_ENCODING | variable | Inherited from Message |
UNKNOWN_CONTENT_LENGTH | variable | Inherited from Message |
UNKNOWN_CONTENT_TYPE | variable | Inherited from Message |
CONTENT_LENGTH | variable | Inherited from Message |
CONTENT_TYPE | variable | Inherited from Message |
TRANSFER_ENCODING | variable | Inherited from Message |
CONNECTION | variable | Inherited from Message |
CONNECTION_KEEP_ALIVE | variable | Inherited from Message |
CONNECTION_CLOSE | variable | Inherited from Message |
EMPTY | variable | Inherited from Message |
_version | variable | Inherited from Message |
Message | function | Inherited from Message |
Message | function | Inherited from Message |
~Message | function | Inherited from Message |
Map | typedef | Inherited from NVCollection |
Iterator | typedef | Inherited from NVCollection |
ConstIterator | typedef | Inherited from NVCollection |
_map | variable | Inherited from NVCollection |
NVCollection | function | Inherited from NVCollection |
NVCollection | function | Inherited from NVCollection |
NVCollection | function | Inherited from NVCollection |
~NVCollection | function | Inherited from NVCollection |
operator= | function | Inherited from NVCollection |
operator= | function | Inherited from NVCollection |
operator[] | function | Inherited from NVCollection |
set | function | Inherited from NVCollection |
add | function | Inherited from NVCollection |
add | function | Inherited from NVCollection |
get | function | Inherited from NVCollection |
get | function | Inherited from NVCollection |
has | function | Inherited from NVCollection |
find | function | Inherited from NVCollection |
begin | function | Inherited from NVCollection |
end | function | Inherited from NVCollection |
empty | function | Inherited from NVCollection |
size | function | Inherited from NVCollection |
erase | function | Inherited from NVCollection |
clear | function | Inherited from NVCollection |
Inherited from Message
| Kind | Name | Description |
|---|---|---|
function | setVersion | Sets the HTTP version for this message. |
function | getVersion const nodiscard | Returns the HTTP version for this message. |
function | setContentLength | Sets the Content-Length header. |
function | getContentLength const nodiscard | Returns the content length for this message, which may be UNKNOWN_CONTENT_LENGTH if no Content-Length header is present. |
function | hasContentLength const nodiscard | Returns true if a Content-Length header is present. |
function | setTransferEncoding | Sets the transfer encoding for this message. |
function | getTransferEncoding const nodiscard | Returns the transfer encoding used for this message. |
function | setChunkedTransferEncoding | If flag is true, sets the Transfer-Encoding header to chunked. Otherwise, removes the Transfer-Encoding header. |
function | isChunkedTransferEncoding const nodiscard | Returns true if the Transfer-Encoding header is set and its value is chunked. |
function | setContentType | Sets the content type for this message. |
function | getContentType const nodiscard | Returns the content type for this message. |
function | setKeepAlive | Sets the value of the Connection header field. |
function | getKeepAlive const nodiscard | Returns true if |
function | write virtual const | Writes the message header to the given output stream. |
function | write virtual const | Writes the message header to the given output string. |
function | write virtual const | Writes the message header directly into a byte buffer. |
variable | HTTP_1_0 static | |
variable | HTTP_1_1 static | |
variable | IDENTITY_TRANSFER_ENCODING static | |
variable | CHUNKED_TRANSFER_ENCODING static | |
variable | UNKNOWN_CONTENT_LENGTH static | |
variable | UNKNOWN_CONTENT_TYPE static | |
variable | CONTENT_LENGTH static | |
variable | CONTENT_TYPE static | |
variable | TRANSFER_ENCODING static | |
variable | CONNECTION static | |
variable | CONNECTION_KEEP_ALIVE static | |
variable | CONNECTION_CLOSE static | |
variable | EMPTY static | |
variable | _version | |
function | Message | Creates the Message with version HTTP/1.0. |
function | Message | Creates the Message and sets the version. |
function | ~Message virtual | Destroys the Message. |
Inherited from NVCollection
| Kind | Name | Description |
|---|---|---|
typedef | Map | |
typedef | Iterator | |
typedef | ConstIterator | |
variable | _map | |
function | NVCollection inline | |
function | NVCollection inline | |
function | NVCollection inline noexcept | |
function | ~NVCollection virtual inline | |
function | operator= | Assigns the name-value pairs of another NVCollection to this one. |
function | operator= noexcept | |
function | operator[] const | Returns the value of the (first) name-value pair with the given name. |
function | set | Sets the value of the (first) name-value pair with the given name. |
function | add | Adds a new name-value pair with the given name and value. |
function | add | Adds a new name-value pair using move semantics. |
function | get const | Returns the value of the first name-value pair with the given name. |
function | get const | Returns 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. |
function | has const | Returns true if there is at least one name-value pair with the given name. |
function | find const | Returns an iterator pointing to the first name-value pair with the given name. |
function | begin const | Returns an iterator pointing to the begin of the name-value pair collection. |
function | end const | Returns an iterator pointing to the end of the name-value pair collection. |
function | empty const | Returns true iff the header does not have any content. |
function | size const | Returns the number of name-value pairs in the collection. |
function | erase | Removes all name-value pairs with the given name. |
function | clear | Removes all name-value pairs and their values. |
Friends
| Name | Description |
|---|---|
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
| Return | Name | Description |
|---|---|---|
Request | Creates a GET / HTTP/1.1 HTTP request. | |
Request | Creates a GET / HTTP/1.x request with the given version (HTTP/1.0 or HTTP/1.1). | |
Request | Creates an HTTP/1.0 request with the given method and URI. | |
Request | Creates an HTTP request with the given method, URI and version. | |
~Request virtual | Destroys the Request. | |
void | setMethod | Sets the method. |
const std::string & | getMethod const nodiscard | Returns the method. |
void | setURI | Sets the request URI. |
void | appendURI | Appends a fragment to the request URI. Used by the parser when llhttp splits the URL across callbacks. |
const std::string & | getURI const nodiscard | Returns the request URI. |
void | setHost | Sets the value of the Host header field. |
void | setHost | Sets the value of the Host header field. |
const std::string & | getHost const nodiscard | Returns the value of the Host header field. |
void | setCookies | Adds a Cookie header with the names and values from cookies. |
void | getCookies const | Fills cookies with the cookies extracted from the Cookie headers in the request. |
void | getURIParameters const | Returns the request URI parameters. |
bool | hasCredentials const nodiscard | Returns true if the request contains authentication information in the form of an Authorization header. |
void | getCredentials const | Returns the authentication scheme and additional authentication information contained in this request. |
void | setCredentials | Sets the authentication scheme and information for this request. |
bool | hasProxyCredentials const nodiscard | Returns true if the request contains proxy authentication information in the form of an Proxy-Authorization header. |
void | getProxyCredentials const | Returns the proxy authentication scheme and additional proxy authentication information contained in this request. |
void | setProxyCredentials | Sets the proxy authentication scheme and information for this request. |
void | write virtual const | Writes the HTTP request to the given output stream. |
void | write virtual const | Writes the HTTP request to the given output string. |
void | write virtual const | Writes 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
| Return | Name | Description |
|---|---|---|
void | getCredentials const | Returns the authentication scheme and additional authentication information contained in the given header of request. |
void | setCredentials | Writes 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
| Return | Name | Description |
|---|---|---|
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
| Name | Kind | Owner |
|---|---|---|
operator<< | friend | Declared here |
Response | function | Declared here |
Response | function | Declared here |
Response | function | Declared here |
Response | function | Declared here |
Response | function | Declared here |
~Response | function | Declared here |
setStatus | function | Declared here |
getStatus | function | Declared here |
setReason | function | Declared here |
getReason | function | Declared here |
setStatusAndReason | function | Declared here |
setDate | function | Declared here |
getDate | function | Declared here |
addCookie | function | Declared here |
getCookies | function | Declared here |
write | function | Declared here |
write | function | Declared here |
write | function | Declared here |
success | function | Declared here |
_status | variable | Declared here |
_reason | variable | Declared here |
setVersion | function | Inherited from Message |
getVersion | function | Inherited from Message |
setContentLength | function | Inherited from Message |
getContentLength | function | Inherited from Message |
hasContentLength | function | Inherited from Message |
setTransferEncoding | function | Inherited from Message |
getTransferEncoding | function | Inherited from Message |
setChunkedTransferEncoding | function | Inherited from Message |
isChunkedTransferEncoding | function | Inherited from Message |
setContentType | function | Inherited from Message |
getContentType | function | Inherited from Message |
setKeepAlive | function | Inherited from Message |
getKeepAlive | function | Inherited from Message |
write | function | Inherited from Message |
write | function | Inherited from Message |
write | function | Inherited from Message |
HTTP_1_0 | variable | Inherited from Message |
HTTP_1_1 | variable | Inherited from Message |
IDENTITY_TRANSFER_ENCODING | variable | Inherited from Message |
CHUNKED_TRANSFER_ENCODING | variable | Inherited from Message |
UNKNOWN_CONTENT_LENGTH | variable | Inherited from Message |
UNKNOWN_CONTENT_TYPE | variable | Inherited from Message |
CONTENT_LENGTH | variable | Inherited from Message |
CONTENT_TYPE | variable | Inherited from Message |
TRANSFER_ENCODING | variable | Inherited from Message |
CONNECTION | variable | Inherited from Message |
CONNECTION_KEEP_ALIVE | variable | Inherited from Message |
CONNECTION_CLOSE | variable | Inherited from Message |
EMPTY | variable | Inherited from Message |
_version | variable | Inherited from Message |
Message | function | Inherited from Message |
Message | function | Inherited from Message |
~Message | function | Inherited from Message |
Map | typedef | Inherited from NVCollection |
Iterator | typedef | Inherited from NVCollection |
ConstIterator | typedef | Inherited from NVCollection |
_map | variable | Inherited from NVCollection |
NVCollection | function | Inherited from NVCollection |
NVCollection | function | Inherited from NVCollection |
NVCollection | function | Inherited from NVCollection |
~NVCollection | function | Inherited from NVCollection |
operator= | function | Inherited from NVCollection |
operator= | function | Inherited from NVCollection |
operator[] | function | Inherited from NVCollection |
set | function | Inherited from NVCollection |
add | function | Inherited from NVCollection |
add | function | Inherited from NVCollection |
get | function | Inherited from NVCollection |
get | function | Inherited from NVCollection |
has | function | Inherited from NVCollection |
find | function | Inherited from NVCollection |
begin | function | Inherited from NVCollection |
end | function | Inherited from NVCollection |
empty | function | Inherited from NVCollection |
size | function | Inherited from NVCollection |
erase | function | Inherited from NVCollection |
clear | function | Inherited from NVCollection |
Inherited from Message
| Kind | Name | Description |
|---|---|---|
function | setVersion | Sets the HTTP version for this message. |
function | getVersion const nodiscard | Returns the HTTP version for this message. |
function | setContentLength | Sets the Content-Length header. |
function | getContentLength const nodiscard | Returns the content length for this message, which may be UNKNOWN_CONTENT_LENGTH if no Content-Length header is present. |
function | hasContentLength const nodiscard | Returns true if a Content-Length header is present. |
function | setTransferEncoding | Sets the transfer encoding for this message. |
function | getTransferEncoding const nodiscard | Returns the transfer encoding used for this message. |
function | setChunkedTransferEncoding | If flag is true, sets the Transfer-Encoding header to chunked. Otherwise, removes the Transfer-Encoding header. |
function | isChunkedTransferEncoding const nodiscard | Returns true if the Transfer-Encoding header is set and its value is chunked. |
function | setContentType | Sets the content type for this message. |
function | getContentType const nodiscard | Returns the content type for this message. |
function | setKeepAlive | Sets the value of the Connection header field. |
function | getKeepAlive const nodiscard | Returns true if |
function | write virtual const | Writes the message header to the given output stream. |
function | write virtual const | Writes the message header to the given output string. |
function | write virtual const | Writes the message header directly into a byte buffer. |
variable | HTTP_1_0 static | |
variable | HTTP_1_1 static | |
variable | IDENTITY_TRANSFER_ENCODING static | |
variable | CHUNKED_TRANSFER_ENCODING static | |
variable | UNKNOWN_CONTENT_LENGTH static | |
variable | UNKNOWN_CONTENT_TYPE static | |
variable | CONTENT_LENGTH static | |
variable | CONTENT_TYPE static | |
variable | TRANSFER_ENCODING static | |
variable | CONNECTION static | |
variable | CONNECTION_KEEP_ALIVE static | |
variable | CONNECTION_CLOSE static | |
variable | EMPTY static | |
variable | _version | |
function | Message | Creates the Message with version HTTP/1.0. |
function | Message | Creates the Message and sets the version. |
function | ~Message virtual | Destroys the Message. |
Inherited from NVCollection
| Kind | Name | Description |
|---|---|---|
typedef | Map | |
typedef | Iterator | |
typedef | ConstIterator | |
variable | _map | |
function | NVCollection inline | |
function | NVCollection inline | |
function | NVCollection inline noexcept | |
function | ~NVCollection virtual inline | |
function | operator= | Assigns the name-value pairs of another NVCollection to this one. |
function | operator= noexcept | |
function | operator[] const | Returns the value of the (first) name-value pair with the given name. |
function | set | Sets the value of the (first) name-value pair with the given name. |
function | add | Adds a new name-value pair with the given name and value. |
function | add | Adds a new name-value pair using move semantics. |
function | get const | Returns the value of the first name-value pair with the given name. |
function | get const | Returns 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. |
function | has const | Returns true if there is at least one name-value pair with the given name. |
function | find const | Returns an iterator pointing to the first name-value pair with the given name. |
function | begin const | Returns an iterator pointing to the begin of the name-value pair collection. |
function | end const | Returns an iterator pointing to the end of the name-value pair collection. |
function | empty const | Returns true iff the header does not have any content. |
function | size const | Returns the number of name-value pairs in the collection. |
function | erase | Removes all name-value pairs with the given name. |
function | clear | Removes all name-value pairs and their values. |
Friends
| Name | Description |
|---|---|
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
| Return | Name | Description |
|---|---|---|
Response | Creates the Response with OK status. | |
Response | Creates the Response with the given status and reason phrase. | |
Response | Creates the Response with the given version, status and reason phrase. | |
Response | Creates the Response with the given status and an appropriate reason phrase. | |
Response | Creates the Response with the given version, status and an appropriate reason phrase. | |
~Response virtual | Destroys the Response. | |
void | setStatus | Sets the HTTP status code. |
StatusCode | getStatus const nodiscard | Returns the HTTP status code. |
void | setReason | Sets the HTTP reason phrase. |
const std::string & | getReason const nodiscard | Returns the HTTP reason phrase. |
void | setStatusAndReason | Sets the HTTP status code and reason phrase. |
void | setDate | Sets the Date header to the given date/time value. |
Timestamp | getDate const nodiscard | Returns the value of the Date header. |
void | addCookie | Adds the cookie to the response by adding a Set-Cookie header. |
void | getCookies const | Returns a vector with all the cookies set in the response header. |
void | write virtual const | Writes the HTTP response headers to the given output stream. |
void | write virtual const | Writes the HTTP response headers to the given output string. |
void | write virtual const | Writes the HTTP response headers directly into a byte buffer. |
bool | success virtual const nodiscard | Returns 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
| Return | Name | Description |
|---|---|---|
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
| Name | Kind | Owner |
|---|---|---|
ServerConnection | friend | Declared here |
Connection | variable | Declared here |
Shutdown | variable | Declared here |
Server | function | Declared here |
Server | function | Declared here |
Server | function | Declared here |
Server | function | Declared here |
start | function | Declared here |
stop | function | Declared here |
setReusePort | function | Declared here |
setMaxPooledConnections | function | Declared here |
setKeepAliveTimeout | function | Declared here |
connectionCount | function | Declared here |
address | function | Declared here |
dateCache | function | Declared here |
_loop | variable | Declared here |
_address | variable | Declared here |
_socket | variable | Declared here |
_timer | variable | Declared here |
_factory | variable | Declared here |
_connections | variable | Declared here |
_pool | variable | Declared here |
_dateCache | variable | Declared here |
_keepAliveTimeout | variable | Declared here |
_reusePort | variable | Declared here |
createResponder | function | Declared here |
onClientSocketAccept | function | Declared here |
onConnectionReady | function | Declared here |
onConnectionClose | function | Declared here |
onSocketClose | function | Declared here |
onTimer | function | Declared here |
loop | function | Declared here |
priority | variable | Inherited from SocketAdapter |
SocketAdapter | function | Inherited from SocketAdapter |
~SocketAdapter | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
setSender | function | Inherited from SocketAdapter |
sender | function | Inherited from SocketAdapter |
addReceiver | function | Inherited from SocketAdapter |
removeReceiver | function | Inherited from SocketAdapter |
hasReceiver | function | Inherited from SocketAdapter |
receivers | function | Inherited from SocketAdapter |
onSocketConnect | function | Inherited from SocketAdapter |
onSocketRecv | function | Inherited from SocketAdapter |
onSocketError | function | Inherited from SocketAdapter |
onSocketClose | function | Inherited from SocketAdapter |
_sender | variable | Inherited from SocketAdapter |
_receivers | variable | Inherited from SocketAdapter |
_dirty | variable | Inherited from SocketAdapter |
cleanupReceivers | function | Inherited from SocketAdapter |
Inherited from SocketAdapter
| Kind | Name | Description |
|---|---|---|
variable | priority | The priority of this adapter for STL sort operations. |
function | SocketAdapter | Creates the SocketAdapter. |
function | ~SocketAdapter virtual noexcept | Destroys the SocketAdapter. |
function | send virtual nodiscard | Sends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | send virtual nodiscard | |
function | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual nodiscard | |
function | sendPacket virtual | Sends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | sendPacket virtual | |
function | sendPacket virtual | Sends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed. |
function | setSender virtual | Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default. |
function | sender | Returns the output SocketAdapter pointer. |
function | addReceiver virtual | Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default. |
function | removeReceiver virtual | Remove the given receiver. |
function | hasReceiver virtual | Returns true if the given receiver is connected. |
function | receivers | Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list. |
function | onSocketConnect virtual | Called when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event. |
function | onSocketRecv virtual | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
variable | _sender | |
variable | _receivers | |
variable | _dirty | |
function | cleanupReceivers virtual |
Friends
| Name | Description |
|---|---|
ServerConnection |
{#serverconnection}
ServerConnection
friend class ServerConnection
Defined in src/http/include/icy/http/server.h:435
Public Attributes
| Return | Name | Description |
|---|---|---|
LocalSignal< void(ServerConnection::Ptr)> | Connection | Signals when a new connection has been created. A reference to the new connection object is provided. |
LocalSignal< void()> | Shutdown | Signals 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
| Return | Name | Description |
|---|---|---|
Server | Constructs an HTTP server on the given host and port using an internally created TCP socket. | |
Server | Constructs an HTTP server on the given address using an internally created TCP socket. | |
Server | 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. | |
Server | Constructs an HTTP server on the given address using a caller-supplied socket. The event loop is derived from the socket. | |
void | start | Start the HTTP server. |
void | stop | Stop the HTTP server. |
void | setReusePort inline | 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+). |
void | setMaxPooledConnections inline | Set the maximum number of pooled connections (default 128). Set to 0 to disable connection pooling entirely. |
void | setKeepAliveTimeout inline | 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. |
size_t | connectionCount const inline nodiscard | Return the number of active connections (all states). |
net::Address & | address nodiscard | Return the server bind address. |
const DateCache & | dateCache const inline nodiscard | Return 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
-
hostBind address (e.g. "0.0.0.0" or "127.0.0.1"). -
portTCP port to listen on. -
loopEvent loop to use. Defaults to the default libuv loop. -
factoryConnection 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
-
addressBind address and port. -
loopEvent loop to use. Defaults to the default libuv loop. -
factoryConnection 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
-
hostBind address. -
portTCP port to listen on. -
socketPre-created socket (e.g. SSLSocket for HTTPS). -
factoryConnection 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
-
addressBind address and port. -
socketPre-created socket (e.g. SSLSocket for HTTPS). -
factoryConnection 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
| Return | Name | Description |
|---|---|---|
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
| Return | Name | Description |
|---|---|---|
std::unique_ptr< ServerResponder > | createResponder | |
void | onClientSocketAccept | |
void | onConnectionReady | |
void | onConnectionClose | |
bool | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
void | onTimer | |
uv::Loop * | loop const inline nodiscard | Return 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
socketThe 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
| Name | Kind | Owner |
|---|---|---|
Payload | variable | Declared here |
Close | variable | Declared here |
ServerConnection | function | Declared here |
server | function | Declared here |
state | function | Declared here |
mode | function | Declared here |
upgraded | function | Declared here |
streaming | function | Declared here |
idleTimeoutEnabled | function | Declared here |
reusableForPool | function | Declared here |
markActive | function | Declared here |
reset | function | Declared here |
touch | function | Declared here |
idleSeconds | function | Declared here |
beginStreaming | function | Declared here |
endStreaming | function | Declared here |
endStreaming | function | Declared here |
sendHeader | function | Declared here |
close | function | Declared here |
_server | variable | Declared here |
_responder | variable | Declared here |
_lastActivity | variable | Declared here |
_state | variable | Declared here |
_mode | variable | Declared here |
onHeaders | function | Declared here |
onPayload | function | Declared here |
onComplete | function | Declared here |
onClose | function | Declared here |
incomingHeader | function | Declared here |
outgoingHeader | function | Declared here |
setState | function | Declared here |
requestHasBody | function | Declared here |
responseLooksStreaming | function | Declared here |
Ptr | typedef | Declared here |
ConnectionStream | friend | Inherited from Connection |
ConnectionAdapter | friend | Inherited from Connection |
Connection | function | Inherited from Connection |
onHeaders | function | Inherited from Connection |
onPayload | function | Inherited from Connection |
onComplete | function | Inherited from Connection |
onClose | function | Inherited from Connection |
send | function | Inherited from Connection |
sendOwned | function | Inherited from Connection |
sendHeader | function | Inherited from Connection |
close | function | Inherited from Connection |
markActive | function | Inherited from Connection |
beginStreaming | function | Inherited from Connection |
endStreaming | function | Inherited from Connection |
closed | function | Inherited from Connection |
error | function | Inherited from Connection |
headerAutoSendEnabled | function | Inherited from Connection |
setHeaderAutoSendEnabled | function | Inherited from Connection |
replaceAdapter | function | Inherited from Connection |
replaceAdapter | function | Inherited from Connection |
secure | function | Inherited from Connection |
socket | function | Inherited from Connection |
adapter | function | Inherited from Connection |
request | function | Inherited from Connection |
response | function | Inherited from Connection |
incomingHeader | function | Inherited from Connection |
outgoingHeader | function | Inherited from Connection |
_socket | variable | Inherited from Connection |
_adapter | variable | Inherited from Connection |
_request | variable | Inherited from Connection |
_response | variable | Inherited from Connection |
_error | variable | Inherited from Connection |
_closed | variable | Inherited from Connection |
_shouldSendHeader | variable | Inherited from Connection |
setError | function | Inherited from Connection |
onSocketConnect | function | Inherited from Connection |
onSocketRecv | function | Inherited from Connection |
onSocketError | function | Inherited from Connection |
onSocketClose | function | Inherited from Connection |
Ptr | typedef | Inherited from Connection |
priority | variable | Inherited from SocketAdapter |
SocketAdapter | function | Inherited from SocketAdapter |
~SocketAdapter | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
setSender | function | Inherited from SocketAdapter |
sender | function | Inherited from SocketAdapter |
addReceiver | function | Inherited from SocketAdapter |
removeReceiver | function | Inherited from SocketAdapter |
hasReceiver | function | Inherited from SocketAdapter |
receivers | function | Inherited from SocketAdapter |
onSocketConnect | function | Inherited from SocketAdapter |
onSocketRecv | function | Inherited from SocketAdapter |
onSocketError | function | Inherited from SocketAdapter |
onSocketClose | function | Inherited from SocketAdapter |
_sender | variable | Inherited from SocketAdapter |
_receivers | variable | Inherited from SocketAdapter |
_dirty | variable | Inherited from SocketAdapter |
cleanupReceivers | function | Inherited from SocketAdapter |
Inherited from Connection
| Kind | Name | Description |
|---|---|---|
friend | ConnectionStream | |
friend | ConnectionAdapter | |
function | Connection | Creates a Connection using the given TCP socket. |
function | onHeaders virtual | Called when the incoming HTTP headers have been fully parsed. |
function | onPayload virtual | Called for each chunk of incoming body data after headers are complete. |
function | onComplete virtual | Called when the incoming HTTP message is fully received. |
function | onClose virtual | Called when the connection is closed. |
function | send virtual override | Send raw data to the peer. |
function | sendOwned virtual override | Send an owned payload buffer to the peer. |
function | sendHeader virtual | Send the outdoing HTTP header. |
function | close virtual | Close the connection and schedule the object for deferred deletion. |
function | markActive virtual inline | Marks the connection as active. Server connections override this to refresh the idle timer. |
function | beginStreaming virtual inline | Explicitly enter long-lived streaming mode. Base connections ignore this; server connections use it to disable keep-alive idle reaping while a response stream is active. |
function | endStreaming virtual inline | Exit long-lived streaming mode. |
function | closed const nodiscard | Return true if the connection is closed. |
function | error const nodiscard | Return the error object if any. |
function | headerAutoSendEnabled const nodiscard | Return true if headers should be automatically sent. |
function | setHeaderAutoSendEnabled | Enable or disable automatic header emission for the next outgoing send path. |
function | replaceAdapter virtual | Assign the new ConnectionAdapter and setup the chain. The flow is: Connection <-> ConnectionAdapter <-> Socket. Takes ownership of the adapter (deferred deletion via uv loop). |
function | replaceAdapter virtual | Overload for nullptr (used in destructor to clear adapter). |
function | secure const nodiscard | Return true if the connection uses TLS/SSL. |
function | socket nodiscard | Return the underlying socket pointer. |
function | adapter const nodiscard | Return the underlying adapter pointer. |
function | request nodiscard | The HTTP request headers. |
function | response nodiscard | The HTTP response headers. |
function | incomingHeader virtual | Returns the incoming HTTP message header (request or response depending on role). |
function | outgoingHeader virtual | Returns the outgoing HTTP message header (request or response depending on role). |
variable | _socket | |
variable | _adapter | |
variable | _request | |
variable | _response | |
variable | _error | |
variable | _closed | |
variable | _shouldSendHeader | |
function | setError virtual | Set the internal error. Note: Setting the error does not [close()](#close-20) the connection. |
function | onSocketConnect virtual override | net::SocketAdapter interface |
function | onSocketRecv virtual override | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual override | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual override | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
typedef | Ptr |
Inherited from SocketAdapter
| Kind | Name | Description |
|---|---|---|
variable | priority | The priority of this adapter for STL sort operations. |
function | SocketAdapter | Creates the SocketAdapter. |
function | ~SocketAdapter virtual noexcept | Destroys the SocketAdapter. |
function | send virtual nodiscard | Sends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | send virtual nodiscard | |
function | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual nodiscard | |
function | sendPacket virtual | Sends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | sendPacket virtual | |
function | sendPacket virtual | Sends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed. |
function | setSender virtual | Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default. |
function | sender | Returns the output SocketAdapter pointer. |
function | addReceiver virtual | Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default. |
function | removeReceiver virtual | Remove the given receiver. |
function | hasReceiver virtual | Returns true if the given receiver is connected. |
function | receivers | Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list. |
function | onSocketConnect virtual | Called when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event. |
function | onSocketRecv virtual | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
variable | _sender | |
variable | _receivers | |
variable | _dirty | |
function | cleanupReceivers virtual |
Public Attributes
| Return | Name | Description |
|---|---|---|
LocalSignal< void(ServerConnection &, const MutableBuffer &)> | Payload | Signals when raw data is received. |
LocalSignal< void(ServerConnection &)> | Close | Signals when the connection is closed. |
{#payload-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
| Return | Name | Description |
|---|---|---|
ServerConnection | Creates a ServerConnection attached to the given server and socket. | |
Server & | server nodiscard | Returns the owning Server instance. |
ServerConnectionState | state const inline nodiscard | Returns the current server-side connection state. |
ServerConnectionMode | mode const inline nodiscard | Returns the current transport mode. |
bool | upgraded const inline nodiscard | Returns true if the connection has been upgraded (e.g. to WebSocket). |
bool | streaming const inline nodiscard | Returns true if the connection is in long-lived streaming mode. |
bool | idleTimeoutEnabled const nodiscard | Returns true if the server idle timer is allowed to reap this connection. |
bool | reusableForPool const nodiscard | Returns true if the closed connection can be returned to the reuse pool. |
void | markActive virtual inline override | Refresh the idle timer. |
void | reset | Reset this connection for reuse with a new socket. Called by the connection pool to avoid allocating a new ServerConnection. |
void | touch inline | Update the last activity timestamp. |
double | idleSeconds const inline nodiscard | Return seconds since last activity. |
void | beginStreaming virtual override | Explicitly mark the response as long-lived streaming. Streaming connections are excluded from the keep-alive idle reaper. |
void | endStreaming virtual override | Exit streaming mode and return to the given HTTP state. |
void | endStreaming | |
ssize_t | sendHeader virtual override | Send the outgoing HTTP header. |
void | close virtual override | Close the connection with an explicit terminal state transition. |
{#serverconnection-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
-
serverThe owning HTTP server instance. -
socketThe 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
| Return | Name | Description |
|---|---|---|
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
| Return | Name | Description |
|---|---|---|
void | onHeaders virtual override | Called when the incoming HTTP headers have been fully parsed. |
void | onPayload virtual override | Called for each chunk of incoming body data after headers are complete. |
void | onComplete virtual override | Called when the incoming HTTP message is fully received. |
void | onClose virtual override | Called when the connection is closed. |
http::Message * | incomingHeader virtual override | Returns the incoming HTTP message header (request or response depending on role). |
http::Message * | outgoingHeader virtual override | Returns the outgoing HTTP message header (request or response depending on role). |
void | setState | |
bool | requestHasBody const nodiscard | |
bool | responseLooksStreaming 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
bufferBuffer 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
| Name | Description |
|---|---|
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
| Name | Kind | Owner |
|---|---|---|
ServerConnectionFactory | function | Declared here |
createConnection | function | Declared here |
createResponder | function | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
ServerConnectionFactory | Defaulted constructor. | |
ServerConnection::Ptr | createConnection virtual inline | Creates the [ServerConnection](#serverconnection-1) wrapper for an accepted TCP socket. |
std::unique_ptr< ServerResponder > | createResponder virtual inline | Creates 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
| Name | Kind | Owner |
|---|---|---|
ServerResponder | function | Declared here |
onHeaders | function | Declared here |
onPayload | function | Declared here |
onRequest | function | Declared here |
onClose | function | Declared here |
connection | function | Declared here |
request | function | Declared here |
response | function | Declared here |
_connection | variable | Declared here |
ServerResponder | function | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
ServerResponder inline | Creates a ServerResponder for the given connection. | |
void | onHeaders virtual inline | Called when the incoming request headers have been parsed. |
void | onPayload virtual inline | Called for each chunk of incoming request body data. |
void | onRequest virtual inline | Called when the complete HTTP request has been received. Derived classes should write their response here. |
void | onClose virtual inline | Called when the connection is closed. |
ServerConnection & | connection inline nodiscard | Returns the underlying server connection. |
Request & | request inline nodiscard | Returns the current HTTP request from the underlying connection. |
Response & | response inline nodiscard | Returns 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
connectionThe 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
requestThe 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
bodyBuffer 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
-
requestThe fully received HTTP request. -
responseThe 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
| Return | Name | Description |
|---|---|---|
ServerConnection & | _connection |
{#_connection-2}
_connection
ServerConnection & _connection
Defined in src/http/include/icy/http/server.h:197
Private Methods
| Return | Name | Description |
|---|---|---|
ServerResponder | Deleted 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
| Name | Kind | Owner |
|---|---|---|
StringPart | function | Declared here |
StringPart | function | Declared here |
~StringPart | function | Declared here |
writeChunk | function | Declared here |
write | function | Declared here |
write | function | Declared here |
length | function | Declared here |
_data | variable | Declared here |
FormPart | function | Inherited from FormPart |
~FormPart | function | Inherited from FormPart |
reset | function | Inherited from FormPart |
writeChunk | function | Inherited from FormPart |
write | function | Inherited from FormPart |
write | function | Inherited from FormPart |
headers | function | Inherited from FormPart |
initialWrite | function | Inherited from FormPart |
contentType | function | Inherited from FormPart |
length | function | Inherited from FormPart |
_contentType | variable | Inherited from FormPart |
_length | variable | Inherited from FormPart |
_headers | variable | Inherited from FormPart |
_initialWrite | variable | Inherited from FormPart |
Inherited from FormPart
| Kind | Name | Description |
|---|---|---|
function | FormPart | Creates the FormPart with the given MIME content type. |
function | ~FormPart virtual | Destroys the FormPart. |
function | reset virtual | Resets the internal state and write position to the beginning. Called by FormWriter when retrying or recalculating content length. |
function | writeChunk virtual | Writes the next chunk of data to the FormWriter. |
function | write virtual | Writes the entire part data to the FormWriter in one call. |
function | write virtual | Writes the entire part data to an output stream (used for content-length calculation). |
function | headers nodiscard | Returns the extra MIME headers for this part (e.g. Content-Disposition). |
function | initialWrite virtual const nodiscard | Returns true if this is the first write call since construction or reset(). |
function | contentType const nodiscard | Returns the MIME content type for this part. |
function | length virtual const nodiscard | Returns the total byte length of the part data. |
variable | _contentType | |
variable | _length | |
variable | _headers | |
variable | _initialWrite |
Public Methods
| Return | Name | Description |
|---|---|---|
StringPart | Creates a StringPart with the given data and default content type "application/octet-stream". | |
StringPart | Creates a StringPart with the given data and MIME content type. | |
~StringPart virtual | Destroys the StringPart. | |
bool | writeChunk virtual override | Writes the string data as a single chunk to the FormWriter. |
void | write virtual override | Writes the string data to the FormWriter. |
void | write virtual override | Writes the string data to an output stream. |
uint64_t | length virtual const nodiscard override | Returns 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
dataString 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
-
dataString data to send as this part. -
contentTypeMIME 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
writerThe FormWriter to send data through.
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
writerThe FormWriter to send data through.
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
ostrOutput 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
| Return | Name | Description |
|---|---|---|
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
| Name | Kind | Owner |
|---|---|---|
operator<< | friend | Declared here |
URL | function | Declared here |
URL | function | Declared here |
URL | function | Declared here |
URL | function | Declared here |
URL | function | Declared here |
URL | function | Declared here |
URL | function | Declared here |
operator= | function | Declared here |
operator= | function | Declared here |
operator= | function | Declared here |
parse | function | Declared here |
scheme | function | Declared here |
userInfo | function | Declared here |
host | function | Declared here |
port | function | Declared here |
authority | function | Declared here |
path | function | Declared here |
pathEtc | function | Declared here |
query | function | Declared here |
fragment | function | Declared here |
hasSchema | function | Declared here |
hasUserInfo | function | Declared here |
hasHost | function | Declared here |
hasPort | function | Declared here |
hasPath | function | Declared here |
hasQuery | function | Declared here |
hasFragment | function | Declared here |
valid | function | Declared here |
str | function | Declared here |
encode | function | Declared here |
decode | function | Declared here |
_buf | variable | Declared here |
_scheme | variable | Declared here |
_userInfo | variable | Declared here |
_host | variable | Declared here |
_port | variable | Declared here |
_path | variable | Declared here |
_query | variable | Declared here |
_fragment | variable | Declared here |
_hasPort | variable | Declared here |
Friends
| Name | Description |
|---|---|
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
| Return | Name | Description |
|---|---|---|
URL | Creates an empty URL. | |
URL | Parses the URL from a null-terminated string. | |
URL | Parses the URL from a std::string. | |
URL | Constructs a URL from scheme and authority components. | |
URL | Constructs a URL from scheme, authority, and path+query+fragment. | |
URL | Constructs a URL from individual components. | |
URL | Defaulted 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. |
bool | parse | Parses and assigns a URL from the given string view, resetting all components first. |
std::string | scheme const nodiscard | Returns the URL scheme (e.g. "http", "https", "ws"). Always lowercase. |
std::string | userInfo const nodiscard | Returns the user info component (e.g. "user:pass" from "http://user:pass@host/"). Returns an empty string if not present. |
std::string | host const nodiscard | Returns the host component (e.g. "example.com"). Returns an empty string if not present. |
uint16_t | port const nodiscard | 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. |
std::string | authority const nodiscard | Returns the authority component (userinfo@[host](#host-1):[port](#port-1)). Only includes components that are present. |
std::string | path const nodiscard | Returns the path component (e.g. "/index.html"). Returns an empty string if not present. |
std::string | pathEtc const nodiscard | Returns the path, query and fragment combined (e.g. "/path?q=1#frag"). |
std::string | query const nodiscard | Returns the query string without the leading '?' (e.g. "key=value&foo=bar"). Returns an empty string if not present. |
std::string | fragment const nodiscard | Returns the fragment identifier without the leading '#'. Returns an empty string if not present. |
bool | hasSchema const nodiscard | Returns true if the URL has a scheme component. |
bool | hasUserInfo const nodiscard | Returns true if the URL has a user info component. |
bool | hasHost const nodiscard | Returns true if the URL has a host component. |
bool | hasPort const nodiscard | Returns true if an explicit port was specified in the URL. |
bool | hasPath const nodiscard | Returns true if the URL has a path component. |
bool | hasQuery const nodiscard | Returns true if the URL has a query component. |
bool | hasFragment const nodiscard | Returns true if the URL has a fragment component. |
bool | valid const nodiscard | Returns true if the URL is non-empty and was successfully parsed. |
std::string | str const nodiscard | Returns 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
urlNull-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
urlURL 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
-
schemeURL scheme (e.g. "http", "https"). -
authorityHost 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
-
schemeURL scheme (e.g. "http"). -
authorityHost and optional port. -
pathEtcPath, 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
-
schemeURL scheme (e.g. "http"). -
authorityHost and optional port. -
pathURL path (e.g. "/index.html"). -
queryQuery string without leading '?' (e.g. "key=value"). -
fragmentFragment 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
uriSource 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
uriNull-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
uriURL 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
-
urlURL string to parse. -
whinyIf 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
| Return | Name | Description |
|---|---|---|
std::string | encode static | Percent-encodes a string per RFC 3986, preserving unreserved characters (A-Z, a-z, 0-9, '-', '_', '.', '~'). Equivalent to JavaScript's encodeURIComponent(). |
std::string | decode static | Decodes 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
strInput 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
strPercent-encoded input string.
Returns
Decoded string.
Protected Attributes
| Return | Name | Description |
|---|---|---|
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
| Name | Kind | Owner |
|---|---|---|
buf | variable | Declared here |
len | variable | Declared here |
lastSecond | variable | Declared here |
update | function | Declared here |
data | function | Declared here |
size | function | Declared here |
Public Attributes
| Return | Name | Description |
|---|---|---|
char | buf | |
size_t | len | |
std::time_t | lastSecond |
{#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
| Return | Name | Description |
|---|---|---|
void | update inline | Refreshes 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 nodiscard | Returns a pointer to the formatted "Date: ...\r\n" header string. |
size_t | size const inline nodiscard | Returns 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
| Name | Kind | Owner |
|---|---|---|
Get | variable | Declared here |
Head | variable | Declared here |
Put | variable | Declared here |
Post | variable | Declared here |
Options | variable | Declared here |
Delete | variable | Declared here |
Trace | variable | Declared here |
Connect | variable | Declared here |
Public Static Attributes
| Return | Name | Description |
|---|---|---|
const std::string | Get static | |
const std::string | Head static | |
const std::string | Put static | |
const std::string | Post static | |
const std::string | Options static | |
const std::string | Delete static | |
const std::string | Trace static | |
const std::string | Connect static |
{#get-4}
Get
static
const std::string Get
Defined in src/http/include/icy/http/request.h:28
{#head}
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
| Name | Kind | Owner |
|---|---|---|
size | variable | Declared here |
lastModified | variable | Declared here |
etag | variable | Declared here |
Public Attributes
| Return | Name | Description |
|---|---|---|
uint64_t | size | File size in bytes. |
Timestamp | lastModified | Last modification time, normalized to HTTP-second precision. |
std::string | etag | Weak 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
| Name | Description |
|---|---|
WebSocketException | |
WebSocketFramer | WebSocket frame encoder/decoder and handshake validator for RFC 6455. |
WebSocketAdapter | WebSocket protocol adapter for both client and server endpoints. |
WebSocket | Standalone WebSocket class. |
ConnectionAdapter | WebSocket class which belongs to an HTTP connection. |
Enumerations
| Name | Description |
|---|---|
Mode | WebSocket endpoint mode. |
FrameFlags | Frame header flags. |
Opcode | Frame header opcodes. |
SendFlags | Combined header flags and opcodes for identifying the payload type of sent frames. |
CloseStatusCode | StatusCodes for CLOSE frames sent with shutdown(). |
ErrorCode | These 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.
| Value | Description |
|---|---|
ServerSide | Server-side WebSocket. |
ClientSide | Client-side WebSocket. |
{#frameflags}
FrameFlags
enum FrameFlags
Frame header flags.
| Value | Description |
|---|---|
Fin | FIN bit: final fragment of a multi-fragment message. |
Rsv1 | Reserved for future use. Must be zero. |
Rsv2 | Reserved for future use. Must be zero. |
Rsv3 | Reserved for future use. Must be zero. |
{#opcode}
Opcode
enum Opcode
Frame header opcodes.
| Value | Description |
|---|---|
Continuation | Continuation frame. |
Text | Text frame. |
Binary | Binary frame. |
Close | Close connection. |
Ping | Ping frame. |
Pong | Pong frame. |
Bitmask | Bit mask for opcodes. |
{#sendflags}
SendFlags
enum SendFlags
Combined header flags and opcodes for identifying the payload type of sent frames.
| Value | Description |
|---|---|
Text | |
Binary |
{#closestatuscode}
CloseStatusCode
enum CloseStatusCode
StatusCodes for CLOSE frames sent with shutdown().
| Value | Description |
|---|---|
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.
| Value | Description |
|---|---|
NoHandshake | No Connection: Upgrade or Upgrade: websocket header in handshake request. |
HandshakeNoVersion | No Sec-WebSocket-Version header in handshake request. |
HandshakeUnsupportedVersion | Unsupported WebSocket version requested by client. |
HandshakeNoKey | No Sec-WebSocket-Key header in handshake request. |
HandshakeAccept | No Sec-WebSocket-Accept header or wrong value. |
Unauthorized | The server rejected the username or password for authentication. |
PayloadTooBig | Payload too big for supplied buffer. |
IncompleteFrame | Incomplete frame received. |
InvalidRsvBits | RSV bits set without extension negotiation. |
InvalidOpcode | Unknown or reserved opcode received. |
UnmaskedClientFrame | Client-to-server frame not masked (RFC 6455 violation). |
ProtocolViolation | General RFC 6455 protocol violation. |
{#closestate}
CloseState
enum CloseState
| Value | Description |
|---|---|
Open | |
CloseSent | |
CloseReceived | |
Closed |
Variables
| Return | Name | Description |
|---|---|---|
auto | ServerSide static constexpr | |
auto | ClientSide static constexpr | |
char | ProtocolGuid constexpr | |
char | ProtocolVersion constexpr | The 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
| Name | Kind | Owner |
|---|---|---|
WebSocketException | function | Declared here |
code | function | Declared here |
hasCloseStatus | function | Declared here |
closeStatus | function | Declared here |
_code | variable | Declared here |
_closeStatus | variable | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
WebSocketException inline | ||
ErrorCode | code const inline nodiscard | |
bool | hasCloseStatus const inline nodiscard | |
uint16_t | closeStatus 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
| Return | Name | Description |
|---|---|---|
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
| Name | Kind | Owner |
|---|---|---|
WebSocketAdapter | friend | Declared here |
wsFramerTestAccess | friend | Declared here |
wsFramerGetFlags | friend | Declared here |
WebSocketFramer | function | Declared here |
writeFrame | function | Declared here |
readFrame | function | Declared here |
handshakeComplete | function | Declared here |
acceptServerRequest | function | Declared here |
createClientHandshakeRequest | function | Declared here |
checkClientHandshakeResponse | function | Declared here |
completeClientHandshake | function | Declared here |
frameFlags | function | Declared here |
mustMaskPayload | function | Declared here |
mode | function | Declared here |
_mode | variable | Declared here |
_frameFlags | variable | Declared here |
_headerState | variable | Declared here |
_maskPayload | variable | Declared here |
_rnd | variable | Declared here |
_key | variable | Declared here |
_fragmented | variable | Declared here |
_fragmentOpcode | variable | Declared here |
_fragmentBuffer | variable | Declared here |
_incompleteFrame | variable | Declared here |
Friends
| Name | Description |
|---|---|
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
| Return | Name | Description |
|---|---|---|
WebSocketFramer | Creates a WebSocketFramer operating in the given endpoint mode. Client-side framers mask outgoing payloads; server-side framers do not. | |
size_t | writeFrame virtual | Encodes data into a WebSocket frame and writes it to frame. |
uint64_t | readFrame virtual | Decodes a single WebSocket frame from frame. |
bool | handshakeComplete const nodiscard | Returns true if the WebSocket handshake has completed successfully. |
void | acceptServerRequest | Server side. |
void | createClientHandshakeRequest | Client side. |
bool | checkClientHandshakeResponse | Validates the server's 101 Switching Protocols response. |
void | completeClientHandshake | Completes 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
modeServerSide 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
-
dataPointer to the payload data. -
lenPayload length in bytes. -
flagsFrame flags: ws::SendFlags::Text, ws::SendFlags::Binary, or a control frame opcode combined with FrameFlags::Fin. -
frameBitWriter to write the encoded frame into.
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
-
frameBitReader positioned at the start of a frame. -
payloadSet to point at the start of the decoded payload. Not null-terminated.
Returns
Payload length in bytes.
Exceptions
std::runtime_erroron 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
-
requestIncoming HTTP upgrade request. -
responseHTTP response to populate with the handshake reply.
Exceptions
std::runtime_errorif 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
requestHTTP 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
responseThe HTTP response received from the server.
Returns
true if the handshake succeeded and data can flow.
Exceptions
std::runtime_errorif 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
responseThe 101 Switching Protocols response from the server.
Exceptions
std::runtime_errorif any required header is missing or incorrect.
Protected Methods
| Return | Name | Description |
|---|---|---|
int | frameFlags const nodiscard | Returns the frame flags of the most recently received frame. Set by readFrame() |
bool | mustMaskPayload const nodiscard | Returns true if the payload must be masked. Used by writeFrame() |
ws::Mode | mode 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
| Return | Name | Description |
|---|---|---|
ws::Mode | _mode | |
int | _frameFlags | |
int | _headerState | |
bool | _maskPayload | |
Random | _rnd | |
std::string | _key | |
bool | _fragmented | Currently receiving a fragmented message. |
int | _fragmentOpcode | Opcode of the first frame in the fragment sequence. |
Buffer | _fragmentBuffer | Accumulated payload from continuation frames. |
Buffer | _incompleteFrame | Buffer 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:
SocketEmitterSubclassed by:ConnectionAdapter,WebSocket
WebSocket protocol adapter for both client and server endpoints.
List of all members
| Name | Kind | Owner |
|---|---|---|
WebSocketFramer | friend | Declared here |
socket | variable | Declared here |
WebSocketAdapter | function | Declared here |
send | function | Declared here |
send | function | Declared here |
sendOwned | function | Declared here |
sendOwned | function | Declared here |
shutdown | function | Declared here |
sendClientRequest | function | Declared here |
handleClientResponse | function | Declared here |
handleServerRequest | function | Declared here |
onHandshakeComplete | function | Declared here |
framer | variable | Declared here |
_request | variable | Declared here |
_response | variable | Declared here |
_closeState | variable | Declared here |
sendControlFrame | function | Declared here |
resetFrameState | function | Declared here |
onSocketConnect | function | Declared here |
onSocketRecv | function | Declared here |
onSocketClose | function | Declared here |
Connect | variable | Inherited from SocketEmitter |
Recv | variable | Inherited from SocketEmitter |
Error | variable | Inherited from SocketEmitter |
Close | variable | Inherited from SocketEmitter |
impl | variable | Inherited from SocketEmitter |
SocketEmitter | function | Inherited from SocketEmitter |
SocketEmitter | function | Inherited from SocketEmitter |
~SocketEmitter | function | Inherited from SocketEmitter |
addReceiver | function | Inherited from SocketEmitter |
removeReceiver | function | Inherited from SocketEmitter |
swap | function | Inherited from SocketEmitter |
as | function | Inherited from SocketEmitter |
operator-> | function | Inherited from SocketEmitter |
onSocketConnect | function | Inherited from SocketEmitter |
onSocketRecv | function | Inherited from SocketEmitter |
onSocketError | function | Inherited from SocketEmitter |
onSocketClose | function | Inherited from SocketEmitter |
priority | variable | Inherited from SocketAdapter |
SocketAdapter | function | Inherited from SocketAdapter |
~SocketAdapter | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
setSender | function | Inherited from SocketAdapter |
sender | function | Inherited from SocketAdapter |
addReceiver | function | Inherited from SocketAdapter |
removeReceiver | function | Inherited from SocketAdapter |
hasReceiver | function | Inherited from SocketAdapter |
receivers | function | Inherited from SocketAdapter |
onSocketConnect | function | Inherited from SocketAdapter |
onSocketRecv | function | Inherited from SocketAdapter |
onSocketError | function | Inherited from SocketAdapter |
onSocketClose | function | Inherited from SocketAdapter |
_sender | variable | Inherited from SocketAdapter |
_receivers | variable | Inherited from SocketAdapter |
_dirty | variable | Inherited from SocketAdapter |
cleanupReceivers | function | Inherited from SocketAdapter |
Inherited from SocketEmitter
| Kind | Name | Description |
|---|---|---|
variable | Connect | Signals that the socket is connected. |
variable | Recv | Signals when data is received by the socket. |
variable | Error | Signals that the socket is closed in error. This signal will be sent just before the Closed signal. |
variable | Close | Signals that the underlying socket is closed. |
variable | impl | Pointer to the underlying socket. Sent data will be proxied to this socket. |
function | SocketEmitter | Creates the SocketEmitter and optionally attaches it to a socket. If socket is provided, this emitter registers itself as a receiver. |
function | SocketEmitter | Copy constructor; copies all signal connections and attaches to the same socket. |
function | ~SocketEmitter virtual noexcept | Destroys the SocketAdapter. |
function | addReceiver virtual override | Attaches a SocketAdapter as a receiver; wires it to all four socket signals. |
function | removeReceiver virtual override | Detaches a SocketAdapter from all four socket signals. |
function | swap virtual | Replaces the underlying socket with socket. |
function | as inline | Returns the underlying socket cast to type T, or nullptr if the cast fails. |
function | operator-> const inline | Returns a raw pointer to the underlying socket for direct method access. Follows shared_ptr semantics; the caller must not delete the returned pointer. |
function | onSocketConnect virtual override | Forwards the connect event to chained adapters, then fires the Connect signal. |
function | onSocketRecv virtual override | Forwards the recv event to chained adapters, then fires the Recv signal. |
function | onSocketError virtual override | Forwards the error event to chained adapters, then fires the Error signal. |
function | onSocketClose virtual override | Forwards the close event to chained adapters, then fires the Close signal. |
Inherited from SocketAdapter
| Kind | Name | Description |
|---|---|---|
variable | priority | The priority of this adapter for STL sort operations. |
function | SocketAdapter | Creates the SocketAdapter. |
function | ~SocketAdapter virtual noexcept | Destroys the SocketAdapter. |
function | send virtual nodiscard | Sends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | send virtual nodiscard | |
function | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual nodiscard | |
function | sendPacket virtual | Sends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | sendPacket virtual | |
function | sendPacket virtual | Sends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed. |
function | setSender virtual | Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default. |
function | sender | Returns the output SocketAdapter pointer. |
function | addReceiver virtual | Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default. |
function | removeReceiver virtual | Remove the given receiver. |
function | hasReceiver virtual | Returns true if the given receiver is connected. |
function | receivers | Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list. |
function | onSocketConnect virtual | Called when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event. |
function | onSocketRecv virtual | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
variable | _sender | |
variable | _receivers | |
variable | _dirty | |
function | cleanupReceivers virtual |
Friends
| Name | Description |
|---|---|
WebSocketFramer |
{#websocketframer-2}
WebSocketFramer
friend class WebSocketFramer
Defined in src/http/include/icy/http/websocket.h:350
Public Attributes
| Return | Name | Description |
|---|---|---|
net::Socket::Ptr | socket | Pointer 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
| Return | Name | Description |
|---|---|---|
WebSocketAdapter | Creates a WebSocketAdapter using the given socket, mode and HTTP message objects. | |
ssize_t | send virtual override | Frames and sends data to the peer's address. |
ssize_t | send virtual override | Frames and sends data to a specific peer address (for UDP-backed sockets). |
ssize_t | sendOwned virtual override | Sends an owned payload buffer to the connected peer. |
ssize_t | sendOwned virtual override | |
bool | shutdown virtual | Sends a WebSocket CLOSE frame with the given status code and message, then closes the underlying socket. |
void | sendClientRequest virtual | Client side. |
void | handleClientResponse virtual | 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. |
void | handleServerRequest virtual | Server side. |
void | onHandshakeComplete virtual | Called 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
-
socketThe underlying TCP or SSL socket. -
modeServerSide or ClientSide. -
requestHTTP request used for the handshake. -
responseHTTP 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
-
dataPointer to the payload. -
lenPayload length in bytes. -
flagsws::SendFlags::Text or ws::SendFlags::Binary.
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
-
dataPointer to the payload. -
lenPayload length in bytes. -
peerAddrDestination address. -
flagsws::SendFlags::Text or ws::SendFlags::Binary.
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
-
statusCodeWebSocket close status code (e.g. 1000 for normal close). -
statusMessageHuman-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
-
bufferBuffer containing the server's HTTP response. -
peerAddrAddress 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
-
bufferBuffer containing the client's HTTP upgrade request. -
peerAddrAddress 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
| Return | Name | Description |
|---|---|---|
WebSocketFramer | framer | |
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
| Return | Name | Description |
|---|---|---|
bool | sendControlFrame | |
void | resetFrameState |
{#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
| Return | Name | Description |
|---|---|---|
bool | onSocketConnect virtual override | Called by the socket on connect; initiates the client handshake. |
bool | onSocketRecv virtual override | Called by the socket on each received buffer; handles handshake or frame parsing depending on state. |
bool | onSocketClose virtual override | Called 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
Inherited from WebSocketAdapter
| Kind | Name | Description |
|---|---|---|
friend | WebSocketFramer | |
variable | socket | Pointer to the underlying socket. Sent data will be proxied to this socket. |
function | WebSocketAdapter | Creates a WebSocketAdapter using the given socket, mode and HTTP message objects. |
function | send virtual override | Frames and sends data to the peer's address. |
function | send virtual override | Frames and sends data to a specific peer address (for UDP-backed sockets). |
function | sendOwned virtual override | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual override | |
function | shutdown virtual | Sends a WebSocket CLOSE frame with the given status code and message, then closes the underlying socket. |
function | sendClientRequest virtual | Client side. |
function | handleClientResponse virtual | 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. |
function | handleServerRequest virtual | Server side. |
function | onHandshakeComplete virtual | Called when the WebSocket handshake completes. Emits the connect event to downstream handlers. |
variable | framer | |
variable | _request | |
variable | _response | |
variable | _closeState | |
function | sendControlFrame | |
function | resetFrameState | |
function | onSocketConnect virtual override | Called by the socket on connect; initiates the client handshake. |
function | onSocketRecv virtual override | Called by the socket on each received buffer; handles handshake or frame parsing depending on state. |
function | onSocketClose virtual override | Called by the socket on close; resets framer state. |
Inherited from SocketEmitter
| Kind | Name | Description |
|---|---|---|
variable | Connect | Signals that the socket is connected. |
variable | Recv | Signals when data is received by the socket. |
variable | Error | Signals that the socket is closed in error. This signal will be sent just before the Closed signal. |
variable | Close | Signals that the underlying socket is closed. |
variable | impl | Pointer to the underlying socket. Sent data will be proxied to this socket. |
function | SocketEmitter | Creates the SocketEmitter and optionally attaches it to a socket. If socket is provided, this emitter registers itself as a receiver. |
function | SocketEmitter | Copy constructor; copies all signal connections and attaches to the same socket. |
function | ~SocketEmitter virtual noexcept | Destroys the SocketAdapter. |
function | addReceiver virtual override | Attaches a SocketAdapter as a receiver; wires it to all four socket signals. |
function | removeReceiver virtual override | Detaches a SocketAdapter from all four socket signals. |
function | swap virtual | Replaces the underlying socket with socket. |
function | as inline | Returns the underlying socket cast to type T, or nullptr if the cast fails. |
function | operator-> const inline | Returns a raw pointer to the underlying socket for direct method access. Follows shared_ptr semantics; the caller must not delete the returned pointer. |
function | onSocketConnect virtual override | Forwards the connect event to chained adapters, then fires the Connect signal. |
function | onSocketRecv virtual override | Forwards the recv event to chained adapters, then fires the Recv signal. |
function | onSocketError virtual override | Forwards the error event to chained adapters, then fires the Error signal. |
function | onSocketClose virtual override | Forwards the close event to chained adapters, then fires the Close signal. |
Inherited from SocketAdapter
| Kind | Name | Description |
|---|---|---|
variable | priority | The priority of this adapter for STL sort operations. |
function | SocketAdapter | Creates the SocketAdapter. |
function | ~SocketAdapter virtual noexcept | Destroys the SocketAdapter. |
function | send virtual nodiscard | Sends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | send virtual nodiscard | |
function | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual nodiscard | |
function | sendPacket virtual | Sends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | sendPacket virtual | |
function | sendPacket virtual | Sends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed. |
function | setSender virtual | Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default. |
function | sender | Returns the output SocketAdapter pointer. |
function | addReceiver virtual | Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default. |
function | removeReceiver virtual | Remove the given receiver. |
function | hasReceiver virtual | Returns true if the given receiver is connected. |
function | receivers | Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list. |
function | onSocketConnect virtual | Called when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event. |
function | onSocketRecv virtual | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
variable | _sender | |
variable | _receivers | |
variable | _dirty | |
function | cleanupReceivers virtual |
Public Methods
| Return | Name | Description |
|---|---|---|
WebSocket | Creates 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 nodiscard | Returns the HTTP request used during the WebSocket handshake. |
http::Response & | response nodiscard | Returns 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
| Return | Name | Description |
|---|---|---|
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
| Name | Description |
|---|---|
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
Inherited from WebSocketAdapter
| Kind | Name | Description |
|---|---|---|
friend | WebSocketFramer | |
variable | socket | Pointer to the underlying socket. Sent data will be proxied to this socket. |
function | WebSocketAdapter | Creates a WebSocketAdapter using the given socket, mode and HTTP message objects. |
function | send virtual override | Frames and sends data to the peer's address. |
function | send virtual override | Frames and sends data to a specific peer address (for UDP-backed sockets). |
function | sendOwned virtual override | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual override | |
function | shutdown virtual | Sends a WebSocket CLOSE frame with the given status code and message, then closes the underlying socket. |
function | sendClientRequest virtual | Client side. |
function | handleClientResponse virtual | 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. |
function | handleServerRequest virtual | Server side. |
function | onHandshakeComplete virtual | Called when the WebSocket handshake completes. Emits the connect event to downstream handlers. |
variable | framer | |
variable | _request | |
variable | _response | |
variable | _closeState | |
function | sendControlFrame | |
function | resetFrameState | |
function | onSocketConnect virtual override | Called by the socket on connect; initiates the client handshake. |
function | onSocketRecv virtual override | Called by the socket on each received buffer; handles handshake or frame parsing depending on state. |
function | onSocketClose virtual override | Called by the socket on close; resets framer state. |
Inherited from SocketEmitter
| Kind | Name | Description |
|---|---|---|
variable | Connect | Signals that the socket is connected. |
variable | Recv | Signals when data is received by the socket. |
variable | Error | Signals that the socket is closed in error. This signal will be sent just before the Closed signal. |
variable | Close | Signals that the underlying socket is closed. |
variable | impl | Pointer to the underlying socket. Sent data will be proxied to this socket. |
function | SocketEmitter | Creates the SocketEmitter and optionally attaches it to a socket. If socket is provided, this emitter registers itself as a receiver. |
function | SocketEmitter | Copy constructor; copies all signal connections and attaches to the same socket. |
function | ~SocketEmitter virtual noexcept | Destroys the SocketAdapter. |
function | addReceiver virtual override | Attaches a SocketAdapter as a receiver; wires it to all four socket signals. |
function | removeReceiver virtual override | Detaches a SocketAdapter from all four socket signals. |
function | swap virtual | Replaces the underlying socket with socket. |
function | as inline | Returns the underlying socket cast to type T, or nullptr if the cast fails. |
function | operator-> const inline | Returns a raw pointer to the underlying socket for direct method access. Follows shared_ptr semantics; the caller must not delete the returned pointer. |
function | onSocketConnect virtual override | Forwards the connect event to chained adapters, then fires the Connect signal. |
function | onSocketRecv virtual override | Forwards the recv event to chained adapters, then fires the Recv signal. |
function | onSocketError virtual override | Forwards the error event to chained adapters, then fires the Error signal. |
function | onSocketClose virtual override | Forwards the close event to chained adapters, then fires the Close signal. |
Inherited from SocketAdapter
| Kind | Name | Description |
|---|---|---|
variable | priority | The priority of this adapter for STL sort operations. |
function | SocketAdapter | Creates the SocketAdapter. |
function | ~SocketAdapter virtual noexcept | Destroys the SocketAdapter. |
function | send virtual nodiscard | Sends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | send virtual nodiscard | |
function | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual nodiscard | |
function | sendPacket virtual | Sends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | sendPacket virtual | |
function | sendPacket virtual | Sends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed. |
function | setSender virtual | Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default. |
function | sender | Returns the output SocketAdapter pointer. |
function | addReceiver virtual | Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default. |
function | removeReceiver virtual | Remove the given receiver. |
function | hasReceiver virtual | Returns true if the given receiver is connected. |
function | receivers | Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list. |
function | onSocketConnect virtual | Called when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event. |
function | onSocketRecv virtual | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
variable | _sender | |
variable | _receivers | |
variable | _dirty | |
function | cleanupReceivers virtual |
Public Methods
| Return | Name | Description |
|---|---|---|
ConnectionAdapter | Creates a ConnectionAdapter for upgrading an existing HTTP connection to WebSocket. Disables automatic header sending on the underlying connection. | |
void | onHandshakeComplete virtual | Called 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
-
connectionThe HTTP connection to upgrade. -
modeServerSide 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
| Return | Name | Description |
|---|---|---|
Connection * | _connection |
{#_connection-3}
_connection
Connection * _connection
Defined in src/http/include/icy/http/websocket.h:410