diff --git a/game/sdl/sdlhttprequest.cpp b/game/sdl/sdlhttprequest.cpp index cbc1acc..4e15949 100644 --- a/game/sdl/sdlhttprequest.cpp +++ b/game/sdl/sdlhttprequest.cpp @@ -120,12 +120,25 @@ void SdlHttpRequest::CreateCurlRequest() { void SdlHttpRequest::SubmitCurlRequest(void *pv) { SdlHttpRequest *req = (SdlHttpRequest *)pv; + // provide a buffer to store errors in + char error[CURL_ERROR_SIZE]; + curl_easy_setopt(req->curl_handle_, CURLOPT_ERRORBUFFER, error); + + // submit CURLcode res = curl_easy_perform(req->curl_handle_); // check for errors if(res != CURLE_OK) { ErrorParams *pparams = new ErrorParams; - strncpyz(pparams->szError, curl_easy_strerror(res), CURL_ERROR_SIZE); + + if (strlen(error)) { + // CURLOPT_ERRORBUFFER messages should be more helpful than curl_easy_strerror + strncpyz(pparams->szError, error, CURL_ERROR_SIZE); + } else { + // Use curl_easy_strerror if CURLOPT_ERRORBUFFER not available + strncpyz(pparams->szError, curl_easy_strerror(res), CURL_ERROR_SIZE); + } + req->thread().Post(kidmError, req, pparams); } else { req->thread().Post(kidmFinishedLoading, req); diff --git a/game/sdl/sdlhttprequest.h b/game/sdl/sdlhttprequest.h index 2e0f93d..bc54713 100644 --- a/game/sdl/sdlhttprequest.h +++ b/game/sdl/sdlhttprequest.h @@ -55,7 +55,7 @@ struct ReceivedDataParams : base::MessageData { }; struct ErrorParams : base::MessageData { - char szError[80]; + char szError[CURL_ERROR_SIZE]; }; } // namespace wi