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 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) |
| 179 { |
| 180 throw std::exception("Can't parse the status code"); |
| 181 } |
179 } | 182 } |
180 statusStr.resize(statusLen / sizeof(std::wstring::value_type) + 1); | 183 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); | 184 res = WinHttpQueryHeaders(hRequest, WINHTTP_QUERY_STATUS_CODE, WINHTTP_HEADER_
NAME_BY_INDEX, &statusStr[0], &statusLen, WINHTTP_NO_HEADER_INDEX); |
182 if ((statusLen == 0) || (!res)) | 185 if ((statusLen == 0) || (!res)) |
183 { | 186 { |
184 throw std::exception("Can't parse the status code"); | 187 throw std::exception("Can't parse the status code"); |
185 } | 188 } |
186 std::wistringstream(statusStr) >> result->responseStatus; | 189 std::wistringstream(statusStr) >> result->responseStatus; |
187 result->status = AdblockPlus::DefaultWebRequest::NS_OK; | 190 result->status = AdblockPlus::DefaultWebRequest::NS_OK; |
188 | 191 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 ZeroMemory(outBuffer.get(), downloadSize+1); | 340 ZeroMemory(outBuffer.get(), downloadSize+1); |
338 | 341 |
339 if (WinHttpReadData(hRequest, outBuffer.get(), downloadSize, &downloaded)) | 342 if (WinHttpReadData(hRequest, outBuffer.get(), downloadSize, &downloaded)) |
340 { | 343 { |
341 result.responseText.append(outBuffer.get(), downloaded); | 344 result.responseText.append(outBuffer.get(), downloaded); |
342 } | 345 } |
343 } | 346 } |
344 } while (downloadSize > 0); | 347 } while (downloadSize > 0); |
345 return result; | 348 return result; |
346 } | 349 } |
OLD | NEW |