reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit 1fe925f3aa6e93f0c963fa7aa861d9f3de1b48b7
parent 6b6a10196604812c7f030c6a37517e8de89c6b42
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Sun, 14 Aug 2016 17:05:14 -0400

download: fix http error reporting when connecting through a proxy

Diffstat:
Msrc/download.cpp | 29++++++-----------------------
1 file changed, 6 insertions(+), 23 deletions(-)

diff --git a/src/download.cpp b/src/download.cpp @@ -148,6 +148,7 @@ DWORD WINAPI Download::Worker(void *ptr) curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, download); curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, UpdateProgress); curl_easy_setopt(curl, CURLOPT_SHARE, g_curlShare); + curl_easy_setopt(curl, CURLOPT_FAILONERROR, true); curl_slist *headers = nullptr; if(download->has(NoCacheFlag)) @@ -176,30 +177,12 @@ DWORD WINAPI Download::Worker(void *ptr) return 1; } - int status = 0; - curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status); - - // accept a status of 0 for the file:// protocol - switch(status) { - case 0: // for the file:// protocol - case 200: // HTTP OK - { - // strip headers - long headerSize = 0; - curl_easy_getinfo(curl, CURLINFO_HEADER_SIZE, &headerSize); - contents.erase(0, headerSize); - - download->finish(Success, contents); - break; - } - default: - // strip body, only keep error description - contents.erase(contents.find("\r")); - contents.erase(0, contents.find("\x20") + 1); + // strip headers + long headerSize = 0; + curl_easy_getinfo(curl, CURLINFO_HEADER_SIZE, &headerSize); + contents.erase(0, headerSize); - download->finish(Failure, contents); - break; - } + download->finish(Success, contents); cleanup();