HTTP module

Client

HTTP client for creating and managing outgoing connections.

#include <icy/http/client.h>

class Client

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

Friends

NameDescription
ClientConnection

ClientConnection

friend class ClientConnection

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

Public Attributes

ReturnNameDescription
NullSignalShutdown

Shutdown

NullSignal Shutdown

Type: NullSignal

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

Public Methods

ReturnNameDescription
Client
~Client virtual
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()

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


~Client

virtual

virtual ~Client()

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


stop

void stop()

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

Stop the Client and close all connections.


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:216

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

Returns

Shared pointer to the created connection.

Parameters

ParameterTypeDescription
urlconst URL &Target URL. The scheme determines the socket and adapter type.
loopuv::Loop *Event loop to use. Defaults to the default libuv loop.

createConnection

inline

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

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

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

Returns

Shared pointer to the created connection.

Parameters

ParameterTypeDescription
urlconst URL &Target URL.
loopuv::Loop *Event loop to use. Defaults to the default libuv loop.

addConnection

virtual

virtual void addConnection(ClientConnection::Ptr conn)

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

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

Parameters

ParameterTypeDescription
connClientConnection::PtrThe connection to add.

removeConnection

virtual

virtual void removeConnection(ClientConnection * conn)

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

Removes a previously registered connection from the client.

Parameters

ParameterTypeDescription
connClientConnection *Raw pointer to the connection to remove.

Exceptions

ExceptionDescription
std::logic_errorif 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()

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

Return the default HTTP Client singleton.


destroy

static

static void destroy()

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

Destroys the default HTTP Client singleton.

Protected Attributes


_connections

ClientConnectionPtrVec _connections

Type: ClientConnectionPtrVec

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

Protected Methods

ReturnNameDescription
voidonConnectionClose

onConnectionClose

void onConnectionClose(Connection & conn)

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