All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
IWebLoadRequest.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Web.h"
6 
7 #include <map>
8 #include <vector>
9 #include <string>
10 
11 namespace Eegeo
12 {
13  namespace Web
14  {
15  typedef std::vector<Byte> TResourceData;
16 
17 
19  {
20  public:
21  WebLoadResponseStatistics(const size_t bytesReadPreDecompress)
22  : BytesReadPreDecompress(bytesReadPreDecompress)
23  {
24 
25  }
26 
27  const size_t BytesReadPreDecompress;
28  };
29 
30 
32  {
33  public:
34  virtual ~IWebLoadRequest() { };
35 
36  virtual void Load() = 0;
37  virtual void Cancel() = 0;
38 
39  virtual HttpVerbs::Values GetHttpVerb() const = 0;
40  virtual std::string GetUrl() const = 0;
41  virtual IWebLoadRequestCompletionCallback& GetCallback() const = 0;
42  virtual void* GetUserData() const = 0;
43  virtual std::string GetUserAgent() const = 0;
44  virtual int GetRetryLimit() const = 0;
45  virtual int GetTimeoutInSeconds() const = 0;
46  virtual const std::map<std::string, std::string>& GetHttpRequestHeaders() const = 0;
47  virtual const std::map<std::string, WebPostData>& GetHttpPostData() const = 0;
48  virtual const WebPostData& GetPostBodyData() const = 0;
49  virtual TWebRequestId GetRequestId() const = 0;
50  virtual bool ShouldCacheAggressively() const = 0;
51  virtual bool CacheOnly() const = 0;
52  virtual bool ShouldCacheResponse() const = 0;
53  virtual const std::vector<std::string>& GetAcceptableMimeTypes() const = 0;
54  virtual const std::vector<std::string>& GetRequiredResponseHeaders() const = 0;
55  };
56 
57 
59  {
60  public:
61  virtual ~IWebResponse() { };
62 
63  virtual bool IsSucceeded() const = 0;
64  virtual bool IsErrored() const = 0;
65  virtual bool IsCancelled() const = 0;
66  virtual bool HasData() const = 0;
67  virtual std::string GetUrl() const = 0;
68  virtual std::string GetBaseUrl() const = 0;
69  virtual HttpVerbs::Values GetHttpVerb() const = 0;
70  virtual int GetHttpStatusCode() const = 0;
71  virtual void* GetUserData() const = 0;
72  virtual const WebPostData& GetPostBodyData() const = 0;
73  virtual const TResourceData& GetHeaderData() const = 0;
74  virtual const TResourceData& GetBodyData() const = 0;
75  virtual WebLoadResponseStatistics GetStatistics() const = 0;
76  virtual bool MatchesRequestId(const TWebRequestId requestId) const = 0;
77  virtual TWebRequestId GetRequestId() const = 0;
78 
79  // sole mutable method
80  virtual const TResourceData* TransferResourceDataOwnership() = 0;
81  };
82  }
83 }