You.i Engine
YiHTTPRequest.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2017. All rights reserved.
2 #ifndef _YI_HTTP_REQUEST_H_
3 #define _YI_HTTP_REQUEST_H_
4 
6 #include "framework/YiPredef.h"
8 #include "network/YiHTTPService.h" // To get access to HTTP_STATUS_CODE
9 #include "network/YiServer.h"
10 #include "network/YiUrl.h"
11 #include "signal/YiSignal.h"
12 #include "utility/YiString.h"
13 
19 #undef DELETE // Microsoft definition
20 
21 // Opaque container for cleanup operations
22 struct OpaqueCleanup;
23 
24 class CYIHTTPRequestPriv;
25 
35 {
36 public:
37 
41  enum METHOD
42  {
43  GET,
44  PUT,
45  POST,
47  };
48 
55  {
58  };
59 
67 
72  CYIHTTPRequest(const CYIUrl &url, CYIHTTPRequest::METHOD eMethod);
73 
79  CYIHTTPRequest(const CYIServer &server);
80 
86  CYIHTTPRequest(const CYIServer &server, const CYIUrl &url, CYIHTTPRequest::METHOD eMethod);
87 
88  virtual ~CYIHTTPRequest();
89 
95  void SetMethod(CYIHTTPRequest::METHOD eMethod);
96 
102  void SetServer(const CYIServer &server);
103 
109  void SetPostData(const CYIString &postData);
110 
114  const std::vector<char> &GetPostData() const;
115 
119  void AddHeader(const CYIString &header);
120 
126  const std::vector<CYIString> &GetHeaders() const;
127 
131  uint64_t GetUniqueID() const;
132 
138  uint32_t GetID() const;
139 
145  void SetID(uint32_t uRequestID);
146 
150  void SetContextID(uint32_t uContextID);
151 
157  uint32_t GetContextID() const;
158 
163  void SetCompressionType(COMPRESSION_TYPE eCompressionType);
164 
170 
174  METHOD GetMethod() const;
175 
179  void SetURL(const CYIUrl &url);
180 
184  const CYIUrl &GetURL() const;
185 
191  const CYIServer GetServer() const;
192 
201  void SetNetworkTimeoutMs(uint32_t uNetworkTimeoutMs);
202 
206  uint32_t GetNetworkTimeoutMs() const;
207 
216  void SetConnectionTimeoutMs(uint32_t uConnectionTimeoutMs);
217 
221  uint32_t GetConnectionTimeoutMs() const;
222 
228  void SetOpaqueCleanupObject(OpaqueCleanup *pCleanup);
229 
235  void SetIsConnectivityProbe(bool bIsConnectivityProbe);
236 
242  bool IsConnectivityProbe() const;
243 
251  void SetUseCookies(bool bUseCookies);
252 
256  bool IsUsingCookies() const;
257 
263  void *GetPriv() const;
264 
270  bool operator==(const CYIHTTPRequest &other) const;
271 
275  bool operator!=(const CYIHTTPRequest &other) const;
276 
277  CYISignal<const std::shared_ptr<CYIHTTPRequest> &, const std::shared_ptr<CYIHTTPResponse> &, bool /* bCachedResponse */> NotifyResponse;
279 
280  CYISignal<const std::shared_ptr<CYIHTTPRequest> &, const std::shared_ptr<CYIHTTPResponse> &, const HTTP_STATUS_CODE> NotifyComplete;
281 
282 private:
283  CYIHTTPRequestPriv *m_pPriv;
284 
286 };
287 
292 #endif // _YI_HTTP_REQUEST_H_
bool IsUsingCookies() const
CYISignal< const std::shared_ptr< CYIHTTPRequest > &, const std::shared_ptr< CYIHTTPResponse > &, const HTTP_STATUS_CODE > NotifyComplete
Emitted when a success or failure response is received, or no response is available. Parameters included are request, response and status code.
Definition: YiHTTPRequest.h:280
void SetContextID(uint32_t uContextID)
void SetIsConnectivityProbe(bool bIsConnectivityProbe)
uint32_t GetConnectionTimeoutMs() const
#define YI_DISALLOW_COPY_AND_ASSIGN(TypeName)
Delete the copy constructor and assignment operator (and consequently the move constructor as well) ...
Definition: YiPredef.h:114
uint64_t GetUniqueID() const
Container class for Unicode strings. Conceptually, a CYIString object is a sequence of Unicode charac...
Definition: YiString.h:35
const std::vector< CYIString > & GetHeaders() const
void AddHeader(const CYIString &header)
Indicates that the server can compress the response data, but is not required to do so...
Definition: YiHTTPRequest.h:57
METHOD
Supported HTTP request methods.
Definition: YiHTTPRequest.h:41
This is the default value, indicating that the server should not compress the response data...
Definition: YiHTTPRequest.h:56
Contains information required to configure and perform a HTTP request.
Definition: YiHTTPRequest.h:34
bool operator!=(const CYIHTTPRequest &other) const
The base class for an object accessible from script source code.
Definition: YiScriptableObject.h:28
void SetCompressionType(COMPRESSION_TYPE eCompressionType)
bool operator==(const CYIHTTPRequest &other) const
const std::vector< char > & GetPostData() const
void SetUseCookies(bool bUseCookies)
This class contains various data used when authenticating with a server.
Definition: YiServer.h:16
void SetNetworkTimeoutMs(uint32_t uNetworkTimeoutMs)
Stores the post data as a resource identified by the request URL.
Definition: YiHTTPRequest.h:44
CYIHTTPRequest::COMPRESSION_TYPE GetCompressionType() const
Retrieve the information identified by the request URL.
Definition: YiHTTPRequest.h:43
Deletes the reseource identified by the request URL.
Definition: YiHTTPRequest.h:46
void SetMethod(CYIHTTPRequest::METHOD eMethod)
const CYIServer GetServer() const
Submits the post data to be processed to a specified resource identified by the request URL...
Definition: YiHTTPRequest.h:45
A class used to encapsulate an URL.
Definition: YiUrl.h:24
virtual ~CYIHTTPRequest()
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 re...
Definition: YiHTTPRequest.h:277
HTTP_STATUS_CODE
Definition: YiHTTPService.h:20
COMPRESSION_TYPE
Provides a hint to the server if compression can be used on the response data.
Definition: YiHTTPRequest.h:54
bool IsConnectivityProbe() const
void SetServer(const CYIServer &server)
const CYIUrl & GetURL() const
uint32_t GetID() const
void SetPostData(const CYIString &postData)
void * GetPriv() const
METHOD GetMethod() const
uint32_t GetNetworkTimeoutMs() const
void SetID(uint32_t uRequestID)
Signals and slots are a thread-safe and flexible communication framework that will allow various obje...
Definition: YiSignal.h:164
void SetConnectionTimeoutMs(uint32_t uConnectionTimeoutMs)
void SetOpaqueCleanupObject(OpaqueCleanup *pCleanup)
void SetURL(const CYIUrl &url)
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.
Definition: YiHTTPRequest.h:278
uint32_t GetContextID() const