diff --git a/nel/include/nel/web/http_client_curl.h b/nel/include/nel/web/http_client_curl.h index cfb1ac38a..babd0d7f9 100644 --- a/nel/include/nel/web/http_client_curl.h +++ b/nel/include/nel/web/http_client_curl.h @@ -63,6 +63,8 @@ public: /// Disconnect if connected (otherwise does nothing) void disconnect(); + const char *lastError() { return &m_ErrorBuf[0]; } + protected: /// Helper @@ -78,6 +80,8 @@ private: std::vector _ReceiveBuffer; std::string _Auth; // must be kept here because curl only stores the char pointer + + std::vector m_ErrorBuf; }; extern CCurlHttpClient CurlHttpClient; diff --git a/nel/src/web/http_client_curl.cpp b/nel/src/web/http_client_curl.cpp index b0ea66de3..446491768 100644 --- a/nel/src/web/http_client_curl.cpp +++ b/nel/src/web/http_client_curl.cpp @@ -124,15 +124,17 @@ bool CCurlHttpClient::sendRequest(const std::string& methodWB, const std::string curl_easy_setopt(_Curl, CURLOPT_WRITEFUNCTION, CCurlHttpClient::writeDataFromCurl); curl_easy_setopt(_Curl, CURLOPT_WRITEDATA, this); - char errorbuf [CURL_ERROR_SIZE+1]; - curl_easy_setopt(_Curl, CURLOPT_ERRORBUFFER, errorbuf); + if (!m_ErrorBuf.size()) + m_ErrorBuf.resize(CURL_ERROR_SIZE + 1); + m_ErrorBuf[0] = '\0'; + curl_easy_setopt(_Curl, CURLOPT_ERRORBUFFER, &m_ErrorBuf[0]); // Send CURLcode res = curl_easy_perform(_Curl); if (res != 0) { if (verbose) - nlwarning(errorbuf); + nlwarning(&m_ErrorBuf[0]); return false; } diff --git a/ryzom/client/src/login.cpp b/ryzom/client/src/login.cpp index bedd66f7c..7b0377890 100644 --- a/ryzom/client/src/login.cpp +++ b/ryzom/client/src/login.cpp @@ -2832,7 +2832,7 @@ string checkLogin(const string &login, const string &password, const string &cli { // ask server for salt if(!HttpClient.sendGet(url + "?cmd=ask&cp=2&login=" + login + "&lg=" + ClientCfg.LanguageCode, "", pPM->isVerboseLog())) - return "Can't send (error code 60)"; + return std::string("Can't send (error code 60) ") + HttpClient.lastError(); if(pPM->isVerboseLog()) nlinfo("Sent request for password salt"); @@ -2906,13 +2906,13 @@ string checkLogin(const string &login, const string &password, const string &cli std::string cryptedPassword = CCrypt::crypt(password, Salt); if(!HttpClient.sendGet(url + "?cmd=login&login=" + login + "&password=" + cryptedPassword + "&clientApplication=" + clientApp + "&cp=2" + "&lg=" + ClientCfg.LanguageCode + customParameters)) - return "Can't send (error code 2)"; + return std::string("Can't send (error code 2) ") + HttpClient.lastError(); } else { // don't send login and password if empty if(!HttpClient.sendGet(url + "?cmd=login&clientApplication=" + clientApp + "&cp=2" + "&lg=" + ClientCfg.LanguageCode + customParameters)) - return "Can't send (error code 2)"; + return std::string("Can't send (error code 2) ") + HttpClient.lastError(); } // the response should contains the result code and the cookie value @@ -3022,7 +3022,7 @@ string checkLogin(const string &login, const string &password, const string &cli std::string cryptedPassword = CCrypt::crypt(password, Salt); if(!HttpClient.sendGet(url + "?login=" + login + "&password=" + cryptedPassword + "&clientApplication=" + clientApp + "&cp=2")) - return "Can't send (error code 2)"; + return std::string("Can't send (error code 2) ") + HttpClient.lastError(); /* if(!send(ClientCfg.ConfigFile.getVar("StartupPage").asString()+"?login="+login+"&password="+password+"&clientApplication="+clientApp)) return "Can't send (error code 2)";