All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
InFlightWebRequest.h
1 #pragma once
2 
3 #include "Types.h"
4 #include "Web.h"
5 #include "IWebLoadRequest.h"
6 #include "WebPostData.h"
7 #include "UrlProxySettings.h"
8 #include "SSLSettings.h"
9 
10 #include <map>
11 #include <string>
12 
13 
14 namespace Eegeo
15 {
16  namespace Web
17  {
24  {
25  public:
26  InFlightWebRequest(const TWebRequestId requestId,
27  const HttpVerbs::Values httpVerb,
28  const std::string& url,
29  const std::string& userAgent,
30  const int retryLimit,
31  const int timeoutInSeconds,
32  const std::map<std::string, std::string>& httpRequestHeaders,
33  const std::map<std::string, WebPostData>& httpPostData,
34  const WebPostData postBodyData,
35  const std::vector<std::string>& acceptableMimeTypes,
36  const std::vector<std::string>& requiredResponseHeaders,
37  const UrlProxySettings& proxySettings,
38  const SSLSettings& sslSettings);
39 
41 
42  TWebRequestId GetRequestId() const;
43  HttpVerbs::Values GetHttpVerb() const;
44  std::string GetUrl() const;
45  std::string GetUserAgent() const;
46  int GetRetryLimit() const;
47  int GetTimeoutInSeconds() const;
48  int GetHttpStatusCode() const;
49  WebLoadResponseCompletionCode::Values GetCompletionCode() const;
50  const std::map<std::string, std::string>& GetHttpRequestHeaders() const;
51  const std::map<std::string, WebPostData>& GetHttpPostData() const;
52  const WebPostData& GetPostBodyData() const;
53  const std::vector<std::string>& GetAcceptableMimeTypes() const;
54  const std::vector<std::string>& GetRequiredResponseHeaders() const;
55  const UrlProxySettings& GetProxySettings() const;
56  const SSLSettings& GetSSLSettings() const;
57 
58  bool HasPostBodyData();
59 
60  bool CanRetry() const;
61  bool HasCacheHeaders() const;
62 
63  const TResourceData& GetHeaderData() const;
64  const TResourceData& GetBodyData() const;
65 
66  bool IsComplete() const;
67  bool IsCancelled() const;
68  size_t GetPreDecompressBytesRead() const;
69 
70  InFlightWebRequest* CreateRetryRequest() const;
71 
72  // mutable stuff
73  void SetComplete(const int httpStatusCode, const WebLoadResponseCompletionCode::Values completionCode);
74  void SetCancelled();
75  void SetPreDecompressBytesRead(size_t numBytes);
76 
77  void AppendHeaderData(Byte* data, size_t size);
78  void AppendBodyData(Byte* data, size_t size);
79  void ReserveBodyDataCapacity(const size_t size);
80 
81  void TransferResourceDataOwnership(TResourceData*& outHeaderData, TResourceData*& outBodyData);
82 
83  private:
84  const TWebRequestId m_requestId;
85  const HttpVerbs::Values m_httpVerb;
86  const std::string m_url;
87  const std::string m_userAgent;
88  const int m_retryLimit;
89  const int m_timeoutInSeconds;
90  const std::map<std::string, std::string> m_httpRequestHeaders;
91  const std::map<std::string, WebPostData> m_httpPostData;
92  const std::vector<std::string> m_acceptableMimeTypes;
93  const std::vector<std::string> m_requiredResponseHeaders;
94  const UrlProxySettings m_proxySettings;
95  const SSLSettings m_sslSettings;
96  const WebPostData m_postBodyData;
97  bool m_hasPostBodyData;
98 
99  bool m_isComplete;
100  int m_httpStatusCode;
101  WebLoadResponseCompletionCode::Values m_completionCode;
102 
103  bool m_isCancelled;
104  size_t m_preDecompressBytesRead;
105 
106  TResourceData* m_pHeaderData;
107  TResourceData* m_pBodyData;
108  };
109  }
110 }