SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWHttpClientManager Class Reference

Provides a high-level interface for issuing HTTP requests using a cache of connected RWHttpClient instances. More...

#include <rw/http/RWHttpClientManager.h>

Public Types

typedef RWTCountingPointer< RWHttpClientManager, RWAtomicCounterPointerType
 

Public Member Functions

 RWHttpClientManager ()
 
 RWHttpClientManager (size_t maxConnections, size_t maxThreads)
 
void closeIfNotUsedSince (const RWHttpDate &date)
 
size_t getMaxConnectionsPerHost () const
 
size_t getMaxThreads () const
 
bool registerScheme (const RWCString &scheme, RWTFunctor< RWHttpClient()> functor)
 
void setMaxConnectionsPerHost (size_t maxConn)
 
void setMaxThreads (size_t maxThreads)
 
bool unregisterScheme (const RWCString &scheme)
 

Detailed Description

RWHttpClientManager provides a resource for pooling connection requests for RWHttpAgent. The RWHttpClientManager is thread-hot, allowing for multiple requests to be processed simultaneously.

Additionally, RWHttpClientManager provides a mechanism for reusing connected clients for multiple requests to the same host.

Member Typedef Documentation

◆ PointerType

Constructor & Destructor Documentation

◆ RWHttpClientManager() [1/2]

RWHttpClientManager::RWHttpClientManager ( )

Constructs a default RWHttpClientManager. The client manager maintains a pool of 20 threads for executing HTTP requests, and allows a maximum of 2 connections to any host (as recommended by the HTTP specification).

◆ RWHttpClientManager() [2/2]

RWHttpClientManager::RWHttpClientManager ( size_t maxConnections,
size_t maxThreads )

Constructs an RWHttpClientManager instance with a pool containing maxThreads threads, and with a limit of maxConnections connections to any host. A maxConnections value of 0 indicates that there is no limit on the number of connections.

Member Function Documentation

◆ closeIfNotUsedSince()

void RWHttpClientManager::closeIfNotUsedSince ( const RWHttpDate & date)

Closes all connections that not have not been used since date.

◆ getMaxConnectionsPerHost()

size_t RWHttpClientManager::getMaxConnectionsPerHost ( ) const
inline

Returns the value for the maximum number of clients allowed to connect to a host.

Note
This value represents the target maximum number of connections per host, not the current number of connections. See the setMaxConnectionsPerHost() method for details on when these values may differ.

◆ getMaxThreads()

size_t RWHttpClientManager::getMaxThreads ( ) const
inline

Returns the value for the maximum number of threads that can be created by the client manager.

Note
This value represents the target maximum number of threads, not the current number of threads in the system. See the setMaxThreads() method for details on when these values may differ.

◆ registerScheme()

bool RWHttpClientManager::registerScheme ( const RWCString & scheme,
RWTFunctor< RWHttpClient()> functor )
inline

Registers a new URL scheme with the client manager. The functor object functor should return an RWHttpClient instance that can correctly handle requests of the associated scheme.

If the specified scheme has already been registered with this instance, the new functor is ignored the method returns false; otherwise, the method returns true.

By default, the only scheme registered with an RWHttpClientManager is "http".

◆ setMaxConnectionsPerHost()

void RWHttpClientManager::setMaxConnectionsPerHost ( size_t maxConn)
inline

Sets the maximum number of clients allowed to connect to a host. If maxConn is set to 0, there is no limit on the number of connections.

Note
If the number of connections is being reduced, the actual number of connections may not decrease immediately if the clients are actively being used. Once a request completes, its connection will be released if the number of connections in the manager is greater than maxConn.

◆ setMaxThreads()

void RWHttpClientManager::setMaxThreads ( size_t maxThreads)
inline

Sets the maximum number of threads that can be created by the client manager.

Note
If the number of threads is being reduced, the actual thread count may not decrease immediately if the threads are actively executing requests. Once a request completes, its thread will be released if the number of threads in the manager is greater than maxThreads.

◆ unregisterScheme()

bool RWHttpClientManager::unregisterScheme ( const RWCString & scheme)
inline

Unregisters the specified URL scheme from the client manager. If the specified scheme is not registered with the client manager instance, the method returns false; otherwise, the scheme is removed and the method returns true.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.