#include <network/YiHTTPService.h>
Public Types | |
enum | HTTPStatusCode { HTTPStatusCode::None = 0, HTTPStatusCode::OK = 200, HTTPStatusCode::NoContent = 204, HTTPStatusCode::RedirectFound = 302, HTTPStatusCode::NotModified = 304, HTTPStatusCode::Unauthorized = 401, HTTPStatusCode::NotFound = 404, HTTPStatusCode::InternalServerError = 500, HTTPStatusCode::YouiNetworkTimedOut = 997, HTTPStatusCode::YouiConnectionTimedOut = 998, HTTPStatusCode::Undefined = 999, HTTPStatusCode::YouiUndefined = Undefined } |
Public Member Functions | |
~CYIHTTPService () | |
void | SetMaxRedirects (uint32_t maxRedirects) |
void | SetNetworkTimeoutMs (uint32_t networkTimeoutMs) |
void | SetConnectionTimeoutMs (uint32_t connectionTimeoutMs) |
void | SetMaxConcurrentConnections (uint32_t maxConnections) |
void | SetNetworkConfiguration (const CYINetworkConfiguration &networkConfiguration) |
void | SetUserAgent (const CYIString &userAgent) |
void | SetProxyUrl (const CYIUrl &proxyUrl) |
void | Start () |
void | Start (const CYINetworkConfiguration &networkConfiguration) |
bool | IsStarted () const |
void | Stop () |
bool | EnqueueRequest (const std::shared_ptr< CYIHTTPRequest > &pRequest) |
void | CancelRequest (const std::shared_ptr< CYIHTTPRequest > &pRequest) |
CYICacheContents | GetCacheContents () const |
void | ClearCache () |
void | ClearCookies () |
![]() | |
virtual | ~IYINetworkService ()=default |
![]() | |
CYISignalHandler () | |
CYISignalHandler (const CYISignalHandler &rSignalHandler) | |
virtual | ~CYISignalHandler () |
CYISignalHandler & | operator= (const CYISignalHandler &rSignalHandler) |
void | MoveToThread (CYIThread *pThread) |
This function allows the user to override the default thread affinity to any CYIThread that may or may not be running. More... | |
CYIThreadHandle | GetThreadAffinity () const |
void | SetThreadAffinity (const CYIThreadHandle &rThreadAffinity) |
virtual bool | IsConnected () const |
virtual bool | IsConnected (const CYISignalBase &rSignal) const |
void | Disconnect (CYISignalBase &rSignal) |
void | DisconnectFromAllSignals () |
![]() | |
Listener () | |
virtual | ~Listener () |
virtual void | OnThreadStarted (CYIThread *) |
virtual void | OnThreadTerminated (CYIThread *) |
virtual void | OnThreadFinished (CYIThread *) |
Static Public Member Functions | |
static CYIHTTPService * | GetInstance () |
static void | SetSSLRootCertificate (const CYIString &rPath) |
Public Attributes | |
CYISignal | ServiceActive |
CYISignal | ServiceInactive |
Friends | |
class | CYIHTTPServicePriv |
|
strong |
CYIHTTPService::~CYIHTTPService | ( | ) |
|
virtual |
Cancels the previously enqueued HTTP request.
Implements IYINetworkService.
void CYIHTTPService::ClearCache | ( | ) |
Clears all cached responses.
void CYIHTTPService::ClearCookies | ( | ) |
Asynchronously clears all stored cookies.
|
virtual |
Queues an HTTP Request for async processing. Returns true if the request is accepted.
Connect to NotifyResponse and NotifyError on pRequest to be notified when the response is ready, or the request failed.
Implements IYINetworkService.
CYICacheContents CYIHTTPService::GetCacheContents | ( | ) | const |
Logs information about cached responses.
|
static |
bool CYIHTTPService::IsStarted | ( | ) | const |
Returns whether the service has been started or not.
void CYIHTTPService::SetConnectionTimeoutMs | ( | uint32_t | connectionTimeoutMs | ) |
Sets the maximum amount of time, in milliseconds, which the connection phase for a request may take. This is the time from when the request is dequeued and the transfer has started to when a response is received from the server.
Default is 30 seconds.
void CYIHTTPService::SetMaxConcurrentConnections | ( | uint32_t | maxConnections | ) |
Sets the maximum number of requests that can be active concurrently. Once the maximum is reached requests will remain in a queue until a request completes.
void CYIHTTPService::SetMaxRedirects | ( | uint32_t | maxRedirects | ) |
Sets the max number of redirects which the HTTP service will follow.
Default is 3.
void CYIHTTPService::SetNetworkConfiguration | ( | const CYINetworkConfiguration & | networkConfiguration | ) |
Sets or modifies the network configuration settings. networkConfiguration allows you to to configure the underlying caches.
Modifying the network configuration after Start() has been called will only affect cache settings.
void CYIHTTPService::SetNetworkTimeoutMs | ( | uint32_t | networkTimeoutMs | ) |
Sets the maximum amount of time, in milliseconds, which a request may take. This is the time from when the request is dequeued and the transfer has started to when the transfer is complete.
Default is 60 seconds.
void CYIHTTPService::SetProxyUrl | ( | const CYIUrl & | proxyUrl | ) |
Set the proxy that will be used for future HTTP requests. Setting the proxy url to an empty url will reset the proxy to use the system settings.
|
static |
Set the SSL root certificate for the network.
void CYIHTTPService::SetUserAgent | ( | const CYIString & | userAgent | ) |
Set the user agent that will be used for future HTTP requests. Setting the user agent to an empty string results in future HTTP requests using the default user agent.
void CYIHTTPService::Start | ( | ) |
Starts the service using the NetworkConfiguration provided by calling SetNetworkConfiguration().
Calling Start() before first calling SetNetworkConfiguration() will result in CYIHTTPService starting with default values for CYINetworkConfiguration::CYINetworkConfiguration. A default persistent cache will be created using the default data path if no cache path is provided.
The service does not accept requests until Start has been called.
void CYIHTTPService::Start | ( | const CYINetworkConfiguration & | networkConfiguration | ) |
Start the service with the provided configuration settings. rNetworkConfiguration allows you to configure the underlying caches. A default persistent cache will be created using the default data path if no cache path is provided.
The service does not accept requests until Start has been called.
void CYIHTTPService::Stop | ( | ) |
Stop the service.
The service does not accept requests once Stop has been called.
|
friend |
CYISignal CYIHTTPService::ServiceActive |
Emitted when the service starts processing requests after a period of inactivity.
CYISignal CYIHTTPService::ServiceInactive |
Emitted when the service has finished processing all queued requests.