You.i Engine
CYIHTTPRequest Class Reference

Detailed Description

Contains information required to configure and perform a HTTP request.

Unique requests can be queued for async processing with CYIHTTPService. Request objects should be retained if cancellation is required.

See also
CYIHTTPService::EnqueueRequest
CYIHTTPService::CancelRequest

#include <network/YiHTTPRequest.h>

Inheritance diagram for CYIHTTPRequest:

Public Types

enum  METHOD {
  GET,
  PUT,
  POST,
  DELETE
}
 Supported HTTP request methods. More...
 
enum  COMPRESSION_TYPE {
  UNCOMPRESSED,
  GZIP
}
 Provides a hint to the server if compression can be used on the response data. More...
 

Public Member Functions

 CYIHTTPRequest ()
 
 CYIHTTPRequest (const CYIUrl &url, CYIHTTPRequest::METHOD eMethod)
 
 CYIHTTPRequest (const CYIServer &server)
 
 CYIHTTPRequest (const CYIServer &server, const CYIUrl &url, CYIHTTPRequest::METHOD eMethod)
 
virtual ~CYIHTTPRequest ()
 
void SetMethod (CYIHTTPRequest::METHOD eMethod)
 
void SetServer (const CYIServer &server)
 
void SetPostData (const CYIString &postData)
 
const std::vector< char > & GetPostData () const
 
void AddHeader (const CYIString &header)
 
const std::vector< CYIString > & GetHeaders () const
 
uint64_t GetUniqueID () const
 
uint32_t GetID () const
 
void SetID (uint32_t uRequestID)
 
void SetContextID (uint32_t uContextID)
 
uint32_t GetContextID () const
 
void SetCompressionType (COMPRESSION_TYPE eCompressionType)
 
CYIHTTPRequest::COMPRESSION_TYPE GetCompressionType () const
 
METHOD GetMethod () const
 
void SetURL (const CYIUrl &url)
 
const CYIUrlGetURL () const
 
const CYIServer GetServer () const
 
void SetNetworkTimeoutMs (uint32_t uNetworkTimeoutMs)
 
uint32_t GetNetworkTimeoutMs () const
 
void SetConnectionTimeoutMs (uint32_t uConnectionTimeoutMs)
 
uint32_t GetConnectionTimeoutMs () const
 
void SetOpaqueCleanupObject (OpaqueCleanup *pCleanup)
 
void SetIsConnectivityProbe (bool bIsConnectivityProbe)
 
bool IsConnectivityProbe () const
 
void SetUseCookies (bool bUseCookies)
 
bool IsUsingCookies () const
 
void * GetPriv () const
 
bool operator== (const CYIHTTPRequest &other) const
 
bool operator!= (const CYIHTTPRequest &other) const
 
- Public Member Functions inherited from CYIScriptableObject
 CYIScriptableObject ()
 
 CYIScriptableObject (const CYIScriptableObject &other)
 
CYIScriptableObjectoperator= (const CYIScriptableObject &other)
 
virtual ~CYIScriptableObject ()
 
CYIBindingImplementationGetBindingImplementation () const
 
void SetBindingImplementation (CYIBindingImplementation *pBindingImplementation)
 
virtual const CYIRuntimeTypeInfoGetRuntimeTypeInfoForScriptObject () const
 

Public Attributes

CYISignal< const std::shared_ptr< CYIHTTPRequest > &, const std::shared_ptr< CYIHTTPResponse > &, bool > NotifyResponse
 Emitted when a response has been received for this request. The bool parameter will be true if the response is a cached response and false if the response is a server response. More...
 
CYISignal< const std::shared_ptr< CYIHTTPRequest > &, const HTTP_STATUS_CODE, const CYIString & > NotifyError
 Emitted when an error occured processing this request, and no response is available. Parameters included are the status code (which may be from the server or locally generated if an error occured during processing) and an error string. More...
 
CYISignal< const std::shared_ptr< CYIHTTPRequest > &, const std::shared_ptr< CYIHTTPResponse > &, const HTTP_STATUS_CODENotifyComplete
 Emitted when a success or failure response is received, or no response is available. Parameters included are request, response and status code. More...
 

Member Enumeration Documentation

Provides a hint to the server if compression can be used on the response data.

See also
SetCompressionType
Enumerator
UNCOMPRESSED 

This is the default value, indicating that the server should not compress the response data.

GZIP 

Indicates that the server can compress the response data, but is not required to do so.

Supported HTTP request methods.

Enumerator
GET 

Retrieve the information identified by the request URL.

PUT 

Stores the post data as a resource identified by the request URL.

POST 

Submits the post data to be processed to a specified resource identified by the request URL.

DELETE 

Deletes the reseource identified by the request URL.

Constructor & Destructor Documentation

CYIHTTPRequest::CYIHTTPRequest ( )

Constucts a new GET request with no url configured.

See also
SetURL
SetMethod
CYIHTTPRequest::CYIHTTPRequest ( const CYIUrl url,
CYIHTTPRequest::METHOD  eMethod 
)
See also
SetURL
SetMethod
CYIHTTPRequest::CYIHTTPRequest ( const CYIServer server)

Constucts a new GET request with no url configured.

See also
SetServer
CYIHTTPRequest::CYIHTTPRequest ( const CYIServer server,
const CYIUrl url,
CYIHTTPRequest::METHOD  eMethod 
)
virtual CYIHTTPRequest::~CYIHTTPRequest ( )
virtual

Member Function Documentation

void CYIHTTPRequest::AddHeader ( const CYIString header)

Adds a header to the request. A header consists of a field name followed by a colon and the field value.

CYIHTTPRequest::COMPRESSION_TYPE CYIHTTPRequest::GetCompressionType ( ) const

Returns the current compression type for the request.

Note
The default compression type is UNCOMPRESSED.
uint32_t CYIHTTPRequest::GetConnectionTimeoutMs ( ) const
uint32_t CYIHTTPRequest::GetContextID ( ) const

Returns the request context ID.

See also
SetContextID(uint32_t)
const std::vector<CYIString>& CYIHTTPRequest::GetHeaders ( ) const

Returns the headers currently attached to the request.

See also
AddHeader
uint32_t CYIHTTPRequest::GetID ( ) const

Returns the user request ID.

See also
SetID(uint32_t)
METHOD CYIHTTPRequest::GetMethod ( ) const

Returns the current method.

uint32_t CYIHTTPRequest::GetNetworkTimeoutMs ( ) const
const std::vector<char>& CYIHTTPRequest::GetPostData ( ) const

Returns the POST data attached to this request.

void* CYIHTTPRequest::GetPriv ( ) const

Returns a raw pointer to the internal private implementation.

For internal use only.

const CYIServer CYIHTTPRequest::GetServer ( ) const

Returns the server for the request.

See also
SetServer
uint64_t CYIHTTPRequest::GetUniqueID ( ) const

Returns the unique request ID.

const CYIUrl& CYIHTTPRequest::GetURL ( ) const

Returns the full URL for the request.

bool CYIHTTPRequest::IsConnectivityProbe ( ) const

Query if the request will be used for connectivity probing.

For interal use by YiConnectivity.

bool CYIHTTPRequest::IsUsingCookies ( ) const

Returns whether the request will include cookies from the cookie store.

bool CYIHTTPRequest::operator!= ( const CYIHTTPRequest other) const
See also
operator==
bool CYIHTTPRequest::operator== ( const CYIHTTPRequest other) const

Compares two requests by their request IDs.

See also
SetID
void CYIHTTPRequest::SetCompressionType ( COMPRESSION_TYPE  eCompressionType)

Sets the allowed compression type for the request.

Note
This does not force compression but allows the server to compress the response data if it has the ability to do so.
void CYIHTTPRequest::SetConnectionTimeoutMs ( uint32_t  uConnectionTimeoutMs)

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.

Note
If not set or set to 0 the CYIHTTPService connection timeout will be set on the request when the request is enqueued.
See also
CYIHTTPService::SetConnectionTimeoutMs
CYIHTTPService::EnqueueRequest
void CYIHTTPRequest::SetContextID ( uint32_t  uContextID)

Sets a context ID, usable by client to identify an individual request.

void CYIHTTPRequest::SetID ( uint32_t  uRequestID)

Sets the user request ID. User request IDs are 0 by default.

Note
The user request ID can be used to differentiate between requests in whatever way makes sense in user code.
void CYIHTTPRequest::SetIsConnectivityProbe ( bool  bIsConnectivityProbe)

Called to tell the system that the request is for connectivity probing.

For internal use by YiConnectivity.

void CYIHTTPRequest::SetMethod ( CYIHTTPRequest::METHOD  eMethod)

Sets the HTTP request method.

See also
METHOD
void CYIHTTPRequest::SetNetworkTimeoutMs ( uint32_t  uNetworkTimeoutMs)

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.

Note
If not set or set to 0 the CYIHTTPService network timeout will be set on the request when the request is enqueued.
See also
CYIHTTPService::SetNetworkTimeoutMs
CYIHTTPService::EnqueueRequest
void CYIHTTPRequest::SetOpaqueCleanupObject ( OpaqueCleanup *  pCleanup)

Sets the opaque container used to clean up private objects.

For internal use only.

void CYIHTTPRequest::SetPostData ( const CYIString postData)

Attach POST data to this request. This data is ignored for GET requests.

Warning
If the data was already set, it will be overwritten by the new post data.
void CYIHTTPRequest::SetServer ( const CYIServer server)

Sets the server for the request, to be used with OAuth requests.

See also
CYIOAuthRequest
void CYIHTTPRequest::SetURL ( const CYIUrl url)

Set the URL for the request.

void CYIHTTPRequest::SetUseCookies ( bool  bUseCookies)

Sets whether cookies from the cookies store are included in the request headers automatically. Cookies are not included by default.

Note
The HTTP Service must have cookie handling enabled via its network configuration for this to work.
See also
CYINetworkConfiguration::SetEnableCookieHandling

Member Data Documentation

CYISignal<const std::shared_ptr<CYIHTTPRequest> &, const std::shared_ptr<CYIHTTPResponse> &, const HTTP_STATUS_CODE> CYIHTTPRequest::NotifyComplete

Emitted when a success or failure response is received, or no response is available. Parameters included are request, response and status code.

See also
HTTP_STATUS_CODE.
CYISignal<const std::shared_ptr<CYIHTTPRequest> &, const HTTP_STATUS_CODE, const CYIString &> CYIHTTPRequest::NotifyError

Emitted when an error occured processing this request, and no response is available. Parameters included are the status code (which may be from the server or locally generated if an error occured during processing) and an error string.

CYISignal<const std::shared_ptr<CYIHTTPRequest> &, const std::shared_ptr<CYIHTTPResponse> &, bool > CYIHTTPRequest::NotifyResponse

Emitted when a response has been received for this request. The bool parameter will be true if the response is a cached response and false if the response is a server response.


The documentation for this class was generated from the following file: