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

Side by Side Diff: include/AdblockPlus/WebRequest.h

Issue 5728380594946048: Issue 116 - Document the libadblockplus API (Closed)
Patch Set: Documented the remaining relevant files Created Aug. 29, 2014, 4:36 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #ifndef ADBLOCK_PLUS_WEB_REQUEST_H 18 #ifndef ADBLOCK_PLUS_WEB_REQUEST_H
19 #define ADBLOCK_PLUS_WEB_REQUEST_H 19 #define ADBLOCK_PLUS_WEB_REQUEST_H
20 20
21 #include <stdint.h> 21 #include <stdint.h>
22 #include <string> 22 #include <string>
23 #include <vector> 23 #include <vector>
24 24
25 #include "tr1_memory.h" 25 #include "tr1_memory.h"
26 26
27 namespace AdblockPlus 27 namespace AdblockPlus
28 { 28 {
29 /**
30 * List of HTTP headers.
31 */
29 typedef std::vector<std::pair<std::string, std::string> > HeaderList; 32 typedef std::vector<std::pair<std::string, std::string> > HeaderList;
30 33
34 /**
35 * HTTP response.
36 */
31 struct ServerResponse 37 struct ServerResponse
32 { 38 {
39 //@{
40 /**
41 * Status code of the response.
Wladimir Palant 2014/08/29 18:42:27 [Mozilla status code](https://developer.mozilla.or
Felix Dahlke 2014/09/01 17:00:15 Done.
42 */
33 #ifdef _WIN32 43 #ifdef _WIN32
34 __int64 status; 44 __int64 status;
35 #else 45 #else
36 int64_t status; 46 int64_t status;
37 #endif 47 #endif
48 //@}
49
50 /**
51 * List of response headers.
52 */
38 HeaderList responseHeaders; 53 HeaderList responseHeaders;
54
55 /**
56 * HTTP status of the response.
Wladimir Palant 2014/08/29 18:42:27 " like 200 or 404"?
Felix Dahlke 2014/09/01 17:00:15 Done.
57 */
39 int responseStatus; 58 int responseStatus;
59
60 /**
61 * Body text of the response.
62 */
40 std::string responseText; 63 std::string responseText;
41 }; 64 };
42 65
66 /**
67 * Web request interface.
68 */
43 class WebRequest 69 class WebRequest
44 { 70 {
45 public: 71 public:
72 /**
73 * Possible response status codes.
74 */
46 enum 75 enum
47 { 76 {
48 NS_OK = 0, 77 NS_OK = 0,
49 NS_ERROR_FAILURE = 0x80004005, 78 NS_ERROR_FAILURE = 0x80004005,
50 NS_ERROR_OUT_OF_MEMORY = 0x8007000e, 79 NS_ERROR_OUT_OF_MEMORY = 0x8007000e,
51 NS_ERROR_MALFORMED_URI = 0x804b000a, 80 NS_ERROR_MALFORMED_URI = 0x804b000a,
52 NS_ERROR_CONNECTION_REFUSED = 0x804b000d, 81 NS_ERROR_CONNECTION_REFUSED = 0x804b000d,
53 NS_ERROR_NET_TIMEOUT = 0x804b000e, 82 NS_ERROR_NET_TIMEOUT = 0x804b000e,
54 NS_ERROR_NO_CONTENT = 0x804b0011, 83 NS_ERROR_NO_CONTENT = 0x804b0011,
55 NS_ERROR_UNKNOWN_PROTOCOL = 0x804b0012, 84 NS_ERROR_UNKNOWN_PROTOCOL = 0x804b0012,
56 NS_ERROR_NET_RESET = 0x804b0014, 85 NS_ERROR_NET_RESET = 0x804b0014,
57 NS_ERROR_UNKNOWN_HOST = 0x804b001e, 86 NS_ERROR_UNKNOWN_HOST = 0x804b001e,
58 NS_ERROR_REDIRECT_LOOP = 0x804b001f, 87 NS_ERROR_REDIRECT_LOOP = 0x804b001f,
59 NS_ERROR_UNKNOWN_PROXY_HOST = 0x804b002a, 88 NS_ERROR_UNKNOWN_PROXY_HOST = 0x804b002a,
60 NS_ERROR_NET_INTERRUPT = 0x804b0047, 89 NS_ERROR_NET_INTERRUPT = 0x804b0047,
61 NS_ERROR_UNKNOWN_PROXY_CONNECTION_REFUSED = 0x804b0048, 90 NS_ERROR_UNKNOWN_PROXY_CONNECTION_REFUSED = 0x804b0048,
62 NS_CUSTOM_ERROR_BASE = 0x80850000, 91 NS_CUSTOM_ERROR_BASE = 0x80850000,
63 NS_ERROR_NOT_INITIALIZED = 0xc1f30001 92 NS_ERROR_NOT_INITIALIZED = 0xc1f30001
64 }; 93 };
65 94
66 virtual inline ~WebRequest() {}; 95 virtual inline ~WebRequest() {};
96
97 /**
98 * Performs a GET request.
99 * @param url Request URL.
100 * @param requestHeaders Request headers.
101 * @return HTTP response.
102 */
67 virtual ServerResponse GET(const std::string& url, const HeaderList& request Headers) const = 0; 103 virtual ServerResponse GET(const std::string& url, const HeaderList& request Headers) const = 0;
68 }; 104 };
69 105
106 /**
107 * Shared smart pointer to a `WebRequest` instance.
108 */
70 typedef std::tr1::shared_ptr<WebRequest> WebRequestPtr; 109 typedef std::tr1::shared_ptr<WebRequest> WebRequestPtr;
71 } 110 }
72 111
73 #endif 112 #endif
OLDNEW
« include/AdblockPlus/ReferrerMapping.h ('K') | « include/AdblockPlus/ReferrerMapping.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld