no error logging for CURL HTTP requests; future callers can request it if necessary
authorPaul Davis <paul@linuxaudiosystems.com>
Sat, 2 Jun 2018 17:24:17 +0000 (13:24 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Sat, 2 Jun 2018 17:24:31 +0000 (13:24 -0400)
gtk2_ardour/add_video_dialog.cc
gtk2_ardour/ardour_http.cc
gtk2_ardour/ardour_http.h
gtk2_ardour/luainstance.cc
gtk2_ardour/luawindow.cc
gtk2_ardour/pingback.cc
gtk2_ardour/utils_videotl.cc
gtk2_ardour/video_image_frame.cc
gtk2_ardour/video_timeline.cc

index 2e092bb4da90161b720a89060e1ef49d81913214..5c0db1ff2631b5d6c9f46b41200f2e65c3f74e85 100644 (file)
@@ -519,7 +519,7 @@ AddVideoDialog::harvid_request(std::string u)
 
        harvid_list->clear();
 
-       char* res = ArdourCurl::http_get (url, &status);
+       char* res = ArdourCurl::http_get (url, &status, false);
        if (status != 200) {
                printf("request failed\n"); // XXX
                harvid_path.set_text(" - request failed -");
@@ -699,7 +699,7 @@ AddVideoDialog::request_preview(std::string u)
                , (long long) (video_duration * seek_slider.get_value() / 1000.0)
                , clip_width, clip_height, u.c_str());
 
-       char* data = ArdourCurl::http_get (url, NULL);
+       char* data = ArdourCurl::http_get (url, NULL, false);
        if (!data) {
                printf("image preview request failed %s\n", url);
                imgbuf->fill(RGBA_TO_UINT(0,0,0,255));
index a67522d90df6af3c3fe2d84f035eb23a5c12f6a5..05e23b32d4fb25ccfc8f02de62080a199b85491b 100644 (file)
@@ -179,13 +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) {
+               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,6 +196,9 @@ HttpGet::get (const char* url)
        }
 
        if (strncmp ("http://", url, 7) && strncmp ("https://", url, 8)) {
+               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
@@ -216,12 +222,18 @@ HttpGet::get (const char* url)
        CCERR ("CURLINFO_RESPONSE_CODE,");
 
        if (_result) {
+               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
@@ -243,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 ();
        }
@@ -253,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);
 }
index aa6b9f3936658aba6119e3af6ca9727258974c3e..41bb2a8f79270bff4b5521be34616b4ba48b5057 100644 (file)
@@ -40,10 +40,10 @@ class HttpGet {
                std::map<std::string, std::string> h;
        };
 
-       char* get (const char* url);
+       char* get (const char* url, bool with_error_logging = false);
 
-       std::string get (const std::string& url) {
-               char *rv = get (url.c_str ());
+       std::string get (const std::string& url, bool with_error_logging = false) {
+               char *rv = get (url.c_str (), with_error_logging);
                return rv ? std::string (rv) : std::string ("");
        }
 
@@ -89,9 +89,14 @@ class HttpGet {
        static const char* ca_info;
 };
 
-char* http_get (const char* url, int* status);
+char* http_get (const char* url, int* status, bool with_error_logging);
+std::string http_get (const std::string& url, bool with_error_logging);
+
+/* For use from Lua scripts */
+
+static char* http_get_unlogged (const char* url, int* status) { return http_get (url, status, false); }
+static std::string http_get_unlogged (const std::string& url) { return http_get (url, false); }
 
-std::string http_get (const std::string& url);
 
 } // namespace
 
index 36436af285f14ce9b9b19ac98b6b3b9b58f45665..8d1644276df555517e0de26e1858e7033dab3a3a 100644 (file)
@@ -744,7 +744,7 @@ LuaInstance::register_classes (lua_State* L)
        luabridge::getGlobalNamespace (L)
                .beginNamespace ("ArdourUI")
 
-               .addFunction ("http_get", (std::string (*)(const std::string&))&ArdourCurl::http_get)
+               .addFunction ("http_get", (std::string (*)(const std::string&))&ArdourCurl::http_get_unlogged)
 
                .addFunction ("processor_selection", &LuaMixer::processor_selection)
 
index d385b8e3c1edb83bc9d67418e56ed5979e733656..59ba451c6ddf7b5b16cecbdfce8053e3cc53b887 100644 (file)
@@ -417,7 +417,7 @@ LuaWindow::import_script ()
        // TODO convert a few URL (eg. pastebin) to raw.
 #if 0
        char *url = "http://pastebin.com/raw/3UMkZ6nV";
-       char *rv = ArdourCurl::http_get (url, 0);
+       char *rv = ArdourCurl::http_get (url, 0. true);
        if (rv) {
                new_script ();
                Glib::RefPtr<Gtk::TextBuffer> tb (entry.get_buffer());
index e641fbd9002250a9c5bd2f4cd81269dd7b610d42..5e747bb4336753ffdcce7781a17f3ec4a8d4e219 100644 (file)
@@ -172,7 +172,7 @@ _pingback (void *arg)
 
 #endif /* PLATFORM_WINDOWS */
 
-       return_str = h.get (url);
+       return_str = h.get (url, false);
 
        if (!return_str.empty ()) {
                if ( return_str.length() > 140 ) { // like a tweet :)
index b6eace7675e28d9f13065b0d03c954a0f514feb8..11b7230dde4c27a504d7f2a9c41eec107611589c 100644 (file)
@@ -273,7 +273,7 @@ VideoUtils::video_query_info (
                        , video_server_url.c_str()
                        , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
                        , filepath.c_str());
-       std::string res = ArdourCurl::http_get (url);
+       std::string res = ArdourCurl::http_get (url, false);
        if (res.empty ()) {
                return false;
        }
index 5d0aea3407de707bf3dd55e0918b04fd2c7d1dc1..2473da0b4e1f603ada21e2bd96a4941295b4affa 100644 (file)
@@ -210,7 +210,7 @@ http_get_thread (void *arg) {
        int timeout = 1000; // * 5ms -> 5sec
        char *res = NULL;
        do {
-               res = ArdourCurl::http_get (url, &status);
+               res = ArdourCurl::http_get (url, &status, false);
                if (status == 503) Glib::usleep(5000); // try-again
        } while (status == 503 && --timeout > 0);
 
index 0c5b0801248512a3714c089fd1f9e37b984fcbce..f16aea8dfae05bae15e488383ac77ec48802953b 100644 (file)
@@ -544,7 +544,7 @@ VideoTimeLine::check_server ()
                        , video_server_url.c_str()
                        , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
                        );
-       char* res = ArdourCurl::http_get (url, NULL);
+       char* res = ArdourCurl::http_get (url, NULL, false);
        if (res) {
                if (strstr(res, "status: ok, online.")) { ok = true; }
                free(res);
@@ -566,7 +566,7 @@ VideoTimeLine::check_server_docroot ()
                        , video_server_url.c_str()
                        , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
                        );
-       char* res = ArdourCurl::http_get (url, NULL);
+       char* res = ArdourCurl::http_get (url, NULL, false);
        if (!res) {
                return false;
        }
@@ -662,7 +662,7 @@ VideoTimeLine::flush_cache () {
                        , video_server_url.c_str()
                        , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
                        );
-       char* res = ArdourCurl::http_get (url, NULL);
+       char* res = ArdourCurl::http_get (url, NULL, false);
        if (res) {
                free (res);
        }