Home
HTTP module

Client

HTTP client for creating and managing outgoing connections.

Client

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

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

HTTP client for creating and managing outgoing connections.

List of all members

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

Friends

NameDescription
ClientConnection

ClientConnection

friend class ClientConnection

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

Public Attributes

ReturnNameDescription
NullSignalShutdown

Shutdown

NullSignal Shutdown

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

Public Methods

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

Client

Client()

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


stop

void stop()

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

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

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

Parameters

Parameters

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

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

Returns

Shared pointer to the created connection.


createConnection

inline

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

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

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

Parameters

  • url Target URL.

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

Returns

Shared pointer to the created connection.


addConnection

virtual

virtual void addConnection(ClientConnection::Ptr conn)

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

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

Parameters

  • conn The connection to add.

removeConnection

virtual

virtual void removeConnection(ClientConnection * conn)

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

Removes a previously registered connection from the client.

Parameters

  • conn Raw pointer to the connection to remove.

Exceptions

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

Public Static Methods

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

instance

static

static Client & instance()

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

Return the default HTTP Client singleton.


destroy

static

static void destroy()

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

Destroys the default HTTP Client singleton.

Protected Attributes

ReturnNameDescription
ClientConnectionPtrVec_connections

_connections

ClientConnectionPtrVec _connections

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

Protected Methods

ReturnNameDescription
voidonConnectionClose

onConnectionClose

void onConnectionClose(Connection & conn)

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