X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fardour_http.cc;h=05e23b32d4fb25ccfc8f02de62080a199b85491b;hb=4423945643bf1a6d2196f1e5882e5fe4bcb6d8cf;hp=2eb04ff367dd4b8b6939790f3e82c1e3a30e8111;hpb=841bbca77329e87e8ce3323ffd087ba2e555bcee;p=ardour.git diff --git a/gtk2_ardour/ardour_http.cc b/gtk2_ardour/ardour_http.cc index 2eb04ff367..05e23b32d4 100644 --- a/gtk2_ardour/ardour_http.cc +++ b/gtk2_ardour/ardour_http.cc @@ -15,7 +15,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#define ARDOURCURLDEBUG + +//#define ARDOURCURLDEBUG #include #include @@ -138,7 +139,7 @@ HttpGet::HttpGet (bool p, bool ssl) , _status (-1) , _result (-1) { - memset (error_buffer, 0, sizeof (*error_buffer)); + error_buffer[0] = 0; _curl = curl_easy_init (); if (!_curl) { @@ -178,14 +179,16 @@ HttpGet::~HttpGet () } char* -HttpGet::get (const char* url) +HttpGet::get (const char* url, bool with_error_logging) { #ifdef ARDOURCURLDEBUG - std::cerr << "HttpGet::get() ---- new request ---"<< std::endl; + std::cerr << "HttpGet::get() ---- new request ---"<< std::endl; #endif _status = _result = -1; if (!_curl || !url) { - PBD::error << "HttpGet::get() not initialized (or NULL url)"<< endmsg; + if (with_error_logging) { + PBD::error << "HttpGet::get() not initialized (or NULL url)"<< endmsg; + } #ifdef ARDOURCURLDEBUG std::cerr << "HttpGet::get() not initialized (or NULL url)"<< std::endl; #endif @@ -193,7 +196,9 @@ HttpGet::get (const char* url) } if (strncmp ("http://", url, 7) && strncmp ("https://", url, 8)) { - PBD::error << "HttpGet::get() not a http[s] URL"<< endmsg; + if (with_error_logging) { + PBD::error << "HttpGet::get() not a http[s] URL"<< endmsg; + } #ifdef ARDOURCURLDEBUG std::cerr << "HttpGet::get() not a http[s] URL"<< std::endl; #endif @@ -204,7 +209,7 @@ HttpGet::get (const char* url) free (mem.data); } // otherwise caller is expected to have free()d or re-used it. - memset (error_buffer, 0, sizeof (*error_buffer)); + error_buffer[0] = 0; mem.data = NULL; mem.size = 0; @@ -217,14 +222,18 @@ HttpGet::get (const char* url) CCERR ("CURLINFO_RESPONSE_CODE,"); if (_result) { - PBD::error << string_compose (_("HTTP request failed: (%1) %2"), _result, error_buffer) << endmsg; + if (with_error_logging) { + PBD::error << string_compose (_("HTTP request failed: (%1) %2"), _result, error_buffer) << endmsg; + } #ifdef ARDOURCURLDEBUG std::cerr << string_compose (_("HTTP request failed: (%1) %2"), _result, error_buffer) << std::endl; #endif return NULL; } if (_status != 200) { + if (with_error_logging) { PBD::error << string_compose (_("HTTP request status: %1"), _status) << endmsg; + } #ifdef ARDOURCURLDEBUG std::cerr << string_compose (_("HTTP request status: %1"), _status) << std::endl; #endif @@ -246,9 +255,9 @@ HttpGet::error () const { } char* -ArdourCurl::http_get (const char* url, int* status) { +ArdourCurl::http_get (const char* url, int* status, bool with_error_logging) { HttpGet h (true); - char* rv = h.get (url); + char* rv = h.get (url, with_error_logging); if (status) { *status = h.status (); } @@ -256,6 +265,6 @@ ArdourCurl::http_get (const char* url, int* status) { } std::string -ArdourCurl::http_get (const std::string& url) { - return HttpGet (false).get (url); +ArdourCurl::http_get (const std::string& url, bool with_error_logging) { + return HttpGet (false).get (url, with_error_logging); }