| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * This file is part of Adblock Plus <https://adblockplus.org/>, | 2  * This file is part of Adblock Plus <https://adblockplus.org/>, | 
| 3  * Copyright (C) 2006-2017 eyeo GmbH | 3  * Copyright (C) 2006-2017 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 <memory> | 21 #include "IWebRequest.h" | 
| 22 #include <stdint.h> |  | 
| 23 #include <string> |  | 
| 24 #include <vector> |  | 
| 25 | 22 | 
| 26 namespace AdblockPlus | 23 namespace AdblockPlus | 
| 27 { | 24 { | 
| 28   /** | 25   /** | 
| 29    * List of HTTP headers. |  | 
| 30    */ |  | 
| 31   typedef std::vector<std::pair<std::string, std::string> > HeaderList; |  | 
| 32 |  | 
| 33   /** |  | 
| 34    * HTTP response. |  | 
| 35    */ |  | 
| 36   struct ServerResponse |  | 
| 37   { |  | 
| 38     //@{ |  | 
| 39     /** |  | 
| 40      * [Mozilla status code](https://developer.mozilla.org/en/docs/Table_Of_Erro
     rs#Network_Errors) |  | 
| 41      * indicating the network-level request status. |  | 
| 42      * This should be 0 (NS_OK) if the request succeeded. Note that this should |  | 
| 43      * be NS_OK if the server responded with an error code like "404 Not Found". |  | 
| 44      */ |  | 
| 45 #ifdef _WIN32 |  | 
| 46     __int64 status; |  | 
| 47 #else |  | 
| 48     int64_t status; |  | 
| 49 #endif |  | 
| 50     //@} |  | 
| 51 |  | 
| 52     /** |  | 
| 53      * List of response headers. |  | 
| 54      */ |  | 
| 55     HeaderList responseHeaders; |  | 
| 56 |  | 
| 57     /** |  | 
| 58      * HTTP status of the response (e.g.\ 404). |  | 
| 59      */ |  | 
| 60     int responseStatus; |  | 
| 61 |  | 
| 62     /** |  | 
| 63      * Body text of the response. |  | 
| 64      */ |  | 
| 65     std::string responseText; |  | 
| 66   }; |  | 
| 67 |  | 
| 68   /** |  | 
| 69    * Web request interface. | 26    * Web request interface. | 
| 70    */ | 27    */ | 
| 71   class WebRequest | 28   class WebRequest | 
| 72   { | 29   { | 
| 73   public: | 30   public: | 
| 74     /** |  | 
| 75      * Possible [Mozilla status codes](https://developer.mozilla.org/en/docs/Tab
     le_Of_Errors#Network_Errors). |  | 
| 76      */ |  | 
| 77     enum |  | 
| 78     { |  | 
| 79       NS_OK = 0, |  | 
| 80       NS_ERROR_FAILURE = 0x80004005, |  | 
| 81       NS_ERROR_OUT_OF_MEMORY = 0x8007000e, |  | 
| 82       NS_ERROR_MALFORMED_URI = 0x804b000a, |  | 
| 83       NS_ERROR_CONNECTION_REFUSED = 0x804b000d, |  | 
| 84       NS_ERROR_NET_TIMEOUT = 0x804b000e, |  | 
| 85       NS_ERROR_NO_CONTENT = 0x804b0011, |  | 
| 86       NS_ERROR_UNKNOWN_PROTOCOL = 0x804b0012, |  | 
| 87       NS_ERROR_NET_RESET = 0x804b0014, |  | 
| 88       NS_ERROR_UNKNOWN_HOST = 0x804b001e, |  | 
| 89       NS_ERROR_REDIRECT_LOOP = 0x804b001f, |  | 
| 90       NS_ERROR_UNKNOWN_PROXY_HOST = 0x804b002a, |  | 
| 91       NS_ERROR_NET_INTERRUPT = 0x804b0047, |  | 
| 92       NS_ERROR_UNKNOWN_PROXY_CONNECTION_REFUSED = 0x804b0048, |  | 
| 93       NS_CUSTOM_ERROR_BASE = 0x80850000, |  | 
| 94       NS_ERROR_NOT_INITIALIZED = 0xc1f30001 |  | 
| 95     }; |  | 
| 96 |  | 
| 97     virtual inline ~WebRequest() {}; | 31     virtual inline ~WebRequest() {}; | 
| 98 | 32 | 
| 99     /** | 33     /** | 
| 100      * Performs a GET request. | 34      * Performs a GET request. | 
| 101      * @param url Request URL. | 35      * @param url Request URL. | 
| 102      * @param requestHeaders Request headers. | 36      * @param requestHeaders Request headers. | 
| 103      * @return HTTP response. | 37      * @return HTTP response. | 
| 104      */ | 38      */ | 
| 105     virtual ServerResponse GET(const std::string& url, const HeaderList& request
     Headers) const = 0; | 39     virtual ServerResponse GET(const std::string& url, const HeaderList& request
     Headers) const = 0; | 
| 106   }; | 40   }; | 
| 107 | 41 | 
| 108   /** | 42   /** | 
| 109    * Shared smart pointer to a `WebRequest` instance. | 43    * Shared smart pointer to a `WebRequest` instance. | 
| 110    */ | 44    */ | 
| 111   typedef std::shared_ptr<WebRequest> WebRequestPtr; | 45   typedef std::shared_ptr<WebRequest> WebRequestSharedPtr; | 
| 112 } | 46 } | 
| 113 | 47 | 
| 114 #endif | 48 #endif | 
| OLD | NEW | 
|---|