OLD | NEW |
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 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 std::pair<std::string, std::string>(headerName, headerValue)); | 165 std::pair<std::string, std::string>(headerName, headerValue)); |
166 | 166 |
167 nextHeaderNameStart++; | 167 nextHeaderNameStart++; |
168 prevHeaderStart = nextHeaderNameStart; | 168 prevHeaderStart = nextHeaderNameStart; |
169 } | 169 } |
170 } | 170 } |
171 | 171 |
172 // Get the response status code | 172 // Get the response status code |
173 std::wstring statusStr; | 173 std::wstring statusStr; |
174 DWORD statusLen = 0; | 174 DWORD statusLen = 0; |
175 res = WinHttpQueryHeaders(hRequest, WINHTTP_QUERY_STATUS_CODE, WINHTTP_HEADER_
NAME_BY_INDEX, &statusStr[0], &statusLen, WINHTTP_NO_HEADER_INDEX); | 175 res = WinHttpQueryHeaders(hRequest, WINHTTP_QUERY_STATUS_CODE, WINHTTP_HEADER_
NAME_BY_INDEX, WINHTTP_NO_OUTPUT_BUFFER, &statusLen, WINHTTP_NO_HEADER_INDEX); |
176 if (statusLen == 0) | 176 if (statusLen == 0) |
177 { | 177 { |
178 throw std::exception("Can't parse the status code"); | 178 throw std::exception("Can't parse the status code"); |
179 } | 179 } |
180 statusStr.resize(statusLen / sizeof(std::wstring::value_type) + 1); | 180 statusStr.resize(statusLen / sizeof(std::wstring::value_type) + 1); |
181 res = WinHttpQueryHeaders(hRequest, WINHTTP_QUERY_STATUS_CODE, WINHTTP_HEADER_
NAME_BY_INDEX, &statusStr[0], &statusLen, WINHTTP_NO_HEADER_INDEX); | 181 res = WinHttpQueryHeaders(hRequest, WINHTTP_QUERY_STATUS_CODE, WINHTTP_HEADER_
NAME_BY_INDEX, &statusStr[0], &statusLen, WINHTTP_NO_HEADER_INDEX); |
182 if ((statusLen == 0) || (!res)) | 182 if ((statusLen == 0) || (!res)) |
183 { | 183 { |
184 throw std::exception("Can't parse the status code"); | 184 throw std::exception("Can't parse the status code"); |
185 } | 185 } |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 ZeroMemory(outBuffer.get(), downloadSize+1); | 337 ZeroMemory(outBuffer.get(), downloadSize+1); |
338 | 338 |
339 if (WinHttpReadData(hRequest, outBuffer.get(), downloadSize, &downloaded)) | 339 if (WinHttpReadData(hRequest, outBuffer.get(), downloadSize, &downloaded)) |
340 { | 340 { |
341 result.responseText.append(outBuffer.get(), downloaded); | 341 result.responseText.append(outBuffer.get(), downloaded); |
342 } | 342 } |
343 } | 343 } |
344 } while (downloadSize > 0); | 344 } while (downloadSize > 0); |
345 return result; | 345 return result; |
346 } | 346 } |
OLD | NEW |