no error logging for CURL HTTP requests; future callers can request it if necessary
This commit is contained in:
parent
820cbc8c4f
commit
f448041ec0
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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 :)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user