HTTP module

Client

HTTP client for creating and managing outgoing connections.

Client

#include <icy/http/client.h>

HTTP client for creating and managing outgoing connections.

Public Attributes

ReturnNameDescription
NullSignalShutdown

Shutdown

NullSignal Shutdown

Public Methods

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

Client

Client()

stop

void stop()

Stop the Client and close all connections.


createConnectionT

inline

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

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

Parameters

Parameters

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

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

Returns

Shared pointer to the created connection.


createConnection

inline

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

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

Parameters

  • url Target URL.

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

Returns

Shared pointer to the created connection.


addConnection

virtual

virtual void addConnection(ClientConnection::Ptr conn)

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

Parameters

  • conn The connection to add.

removeConnection

virtual

virtual void removeConnection(ClientConnection * conn)

Removes a previously registered connection from the client.

Parameters

  • conn Raw pointer to the connection to remove.

Exceptions

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

Public Static Methods

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

instance

static

static Client & instance()

Return the default HTTP Client singleton.


destroy

static

static void destroy()

Destroys the default HTTP Client singleton.

Protected Attributes

ReturnNameDescription
ClientConnectionPtrVec_connections

_connections

ClientConnectionPtrVec _connections

Protected Methods

ReturnNameDescription
voidonConnectionClose

onConnectionClose

void onConnectionClose(Connection & conn)