All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WebRequest.h
1 // Copyright eeGeo Ltd (2012-2015), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Web.h"
6 #include "Types.h"
7 #include "IWebLoadRequest.h"
8 #include "WebPostData.h"
9 
10 #include <string>
11 #include <vector>
12 #include <map>
13 
14 namespace Eegeo
15 {
16  namespace Web
17  {
25  {
26  public:
27 
28  WebRequest(
29  const TWebRequestId requestId,
30  Eegeo::Web::IWebRequestService& m_webRequestService,
31  const HttpVerbs::Values httpVerb,
32  const std::string& url,
34  void* const pUserData,
35  const WebPostData postBodyData,
36  const std::string& userAgent,
37  const int retryLimit,
38  const int timeoutInSeconds,
39  const std::map<std::string, std::string> httpRequestHeaders,
40  const std::map<std::string, WebPostData> httpPostData,
41  const bool shouldCacheAggressively,
42  const bool cacheOnly,
43  const bool shouldCacheResponse,
44  const std::vector<std::string>& acceptableMimeTypes,
45  const std::vector<std::string>& requiredResponseHeaders);
46 
47  ~WebRequest();
48 
49  // mutate
50  void Load();
51  void Cancel();
52 
53  // immutable
54  HttpVerbs::Values GetHttpVerb() const;
55  std::string GetUrl() const;
56  IWebLoadRequestCompletionCallback& GetCallback() const;
57  void* GetUserData() const;
58  const WebPostData& GetPostBodyData() const;
59  std::string GetUserAgent() const;
60  int GetRetryLimit() const;
61  int GetTimeoutInSeconds() const;
62  const std::map<std::string, std::string>& GetHttpRequestHeaders() const;
63  const std::map<std::string, WebPostData>& GetHttpPostData() const;
64  TWebRequestId GetRequestId() const;
65  bool ShouldCacheAggressively() const;
66  bool CacheOnly() const;
67  bool ShouldCacheResponse() const;
68  const std::vector<std::string>& GetAcceptableMimeTypes() const;
69  const std::vector<std::string>& GetRequiredResponseHeaders() const;
70 
71  private:
72  // immutable
73  const TWebRequestId m_requestId;
74  const HttpVerbs::Values m_httpVerb;
75  const std::string m_url;
77  void* const m_pUserData;
78  const std::string m_userAgent;
79  const WebPostData m_postBodyData;
80  const int m_retryLimit;
81  const int m_timeoutInSeconds;
82  const std::map<std::string, std::string> m_httpRequestHeaders;
83  const std::map<std::string, WebPostData> m_httpPostData;
84  const bool m_shouldCacheAggressively;
85  const bool m_cacheOnly;
86  const bool m_shouldCacheResponse;
87  const std::vector<std::string> m_acceptableMimeTypes;
88  const std::vector<std::string> m_requiredResponseHeaders;
89 
90  Eegeo::Web::IWebRequestService& m_webRequestService;
91 
92  // mutable
93  bool m_cancelIssued;
94  bool m_loadIssued;
95  };
96  }
97 }