Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: include/AdblockPlus/WebRequest.h

Issue 10252013: Implemented curl support for web requests (Closed)
Left Patch Set: Made abpshell use DefaultWebRequest Created April 11, 2013, 3:55 p.m.
Right Patch Set: Addressed review comments Created April 12, 2013, 1:37 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « check_curl.py ('k') | libadblockplus.gyp » ('j') | test/WebRequest.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #ifndef ADBLOCKPLUS_WEB_REQUEST_H 1 #ifndef ADBLOCKPLUS_WEB_REQUEST_H
2 #define ADBLOCKPLUS_WEB_REQUEST_H 2 #define ADBLOCKPLUS_WEB_REQUEST_H
3 3
4 #include <string> 4 #include <string>
5 #include <vector> 5 #include <vector>
6 6
7 enum
8 {
9 NS_OK = 0,
10 NS_ERROR_FAILURE = 0x80004005,
11 NS_ERROR_OUT_OF_MEMORY = 0x8007000e,
12 NS_ERROR_MALFORMED_URI = 0x804b000a,
13 NS_ERROR_CONNECTION_REFUSED = 0x804b000d,
14 NS_ERROR_NET_TIMEOUT = 0x804b000e,
15 NS_ERROR_NO_CONTENT = 0x804b0011,
16 NS_ERROR_UNKNOWN_PROTOCOL = 0x804b0012,
17 NS_ERROR_NET_RESET = 0x804b0014,
18 NS_ERROR_UNKNOWN_HOST = 0x804b001e,
19 NS_ERROR_REDIRECT_LOOP = 0x804b001f,
20 NS_ERROR_UNKNOWN_PROXY_HOST = 0x804b002a,
21 NS_ERROR_NOT_INITIALIZED = 0xc1f30001,
22 NS_CUSTOM_ERROR_BASE = 0x80850000
23 };
24
25 namespace AdblockPlus 7 namespace AdblockPlus
26 { 8 {
27 typedef std::vector< std::pair<std::string, std::string> > HeadersList; 9 typedef std::vector<std::pair<std::string, std::string> > HeaderList;
28 10
29 struct ServerResponse 11 struct ServerResponse
30 { 12 {
31 unsigned int status; 13 unsigned int status;
32 HeadersList responseHeaders; 14 HeaderList responseHeaders;
33 int responseStatus; 15 int responseStatus;
34 std::string responseText; 16 std::string responseText;
35 }; 17 };
36 18
37 class WebRequest 19 class WebRequest
38 { 20 {
39 public: 21 public:
40 virtual ~WebRequest(); 22 enum
41 virtual ServerResponse GET(const std::string& url, const HeadersList& reques tHeaders) const = 0; 23 {
24 NS_OK = 0,
25 NS_ERROR_FAILURE = 0x80004005,
26 NS_ERROR_OUT_OF_MEMORY = 0x8007000e,
27 NS_ERROR_MALFORMED_URI = 0x804b000a,
28 NS_ERROR_CONNECTION_REFUSED = 0x804b000d,
29 NS_ERROR_NET_TIMEOUT = 0x804b000e,
30 NS_ERROR_NO_CONTENT = 0x804b0011,
31 NS_ERROR_UNKNOWN_PROTOCOL = 0x804b0012,
32 NS_ERROR_NET_RESET = 0x804b0014,
33 NS_ERROR_UNKNOWN_HOST = 0x804b001e,
34 NS_ERROR_REDIRECT_LOOP = 0x804b001f,
35 NS_ERROR_UNKNOWN_PROXY_HOST = 0x804b002a,
36 NS_ERROR_NOT_INITIALIZED = 0xc1f30001,
37 NS_CUSTOM_ERROR_BASE = 0x80850000
38 };
39
40 virtual inline ~WebRequest() {};
Felix Dahlke 2013/04/16 12:21:09 Oh, just noticed, inline is actually not necessary
Wladimir Palant 2013/04/16 13:30:32 Let's remove it everywhere then later, not only in
Felix Dahlke 2013/04/16 14:51:37 Okay.
41 virtual ServerResponse GET(const std::string& url, const HeaderList& request Headers) const = 0;
42 }; 42 };
43 43
44 class DefaultWebRequest : public WebRequest 44 class DefaultWebRequest : public WebRequest
45 { 45 {
Oleksandr 2013/04/16 12:02:01 I don't quite understand the logic behind this nam
Felix Dahlke 2013/04/16 12:21:09 Yeah, most likely. We cannot really use curl on An
Oleksandr 2013/04/16 12:26:18 Let me rephrase my question: why do all implementa
Wladimir Palant 2013/04/16 13:30:32 The thinking behind this: 1) We have clear prefer
46 ServerResponse GET(const std::string& url, const HeadersList& requestHeaders ) const; 46 ServerResponse GET(const std::string& url, const HeaderList& requestHeaders) const;
47 }; 47 };
48 } 48 }
49 49
50 #endif 50 #endif
LEFTRIGHT

Powered by Google App Engine
This is Rietveld