OLD | NEW |
1 #ifndef ADBLOCKPLUS_WEB_REQUEST_H | 1 #ifndef ADBLOCKPLUS_DEFAULT_WEB_REQUEST_H |
2 #define ADBLOCKPLUS_WEB_REQUEST_H | 2 #define ADBLOCKPLUS_DEFAULT_WEB_REQUEST_H |
3 | 3 |
4 #include <string> | 4 #include "WebRequest.h" |
5 #include <vector> | |
6 | 5 |
7 namespace AdblockPlus | 6 namespace AdblockPlus |
8 { | 7 { |
9 typedef std::vector<std::pair<std::string, std::string> > HeaderList; | |
10 | |
11 struct ServerResponse | |
12 { | |
13 #ifdef _WIN32 | |
14 __int64 status; | |
15 #else | |
16 int64_t status; | |
17 #endif | |
18 HeaderList responseHeaders; | |
19 int responseStatus; | |
20 std::string responseText; | |
21 }; | |
22 | |
23 class WebRequest | |
24 { | |
25 public: | |
26 enum | |
27 { | |
28 NS_OK = 0, | |
29 NS_ERROR_FAILURE = 0x80004005, | |
30 NS_ERROR_OUT_OF_MEMORY = 0x8007000e, | |
31 NS_ERROR_MALFORMED_URI = 0x804b000a, | |
32 NS_ERROR_CONNECTION_REFUSED = 0x804b000d, | |
33 NS_ERROR_NET_TIMEOUT = 0x804b000e, | |
34 NS_ERROR_NO_CONTENT = 0x804b0011, | |
35 NS_ERROR_UNKNOWN_PROTOCOL = 0x804b0012, | |
36 NS_ERROR_NET_RESET = 0x804b0014, | |
37 NS_ERROR_UNKNOWN_HOST = 0x804b001e, | |
38 NS_ERROR_REDIRECT_LOOP = 0x804b001f, | |
39 NS_ERROR_UNKNOWN_PROXY_HOST = 0x804b002a, | |
40 NS_ERROR_NOT_INITIALIZED = 0xc1f30001, | |
41 NS_CUSTOM_ERROR_BASE = 0x80850000 | |
42 }; | |
43 | |
44 virtual inline ~WebRequest() {}; | |
45 virtual ServerResponse GET(const std::string& url, const HeaderList& request
Headers) const = 0; | |
46 }; | |
47 | |
48 class DefaultWebRequest : public WebRequest | 8 class DefaultWebRequest : public WebRequest |
49 { | 9 { |
50 ServerResponse GET(const std::string& url, const HeaderList& requestHeaders)
const; | 10 ServerResponse GET(const std::string& url, const HeaderList& requestHeaders)
const; |
51 }; | 11 }; |
52 } | 12 } |
53 | 13 |
54 #endif | 14 #endif |
OLD | NEW |