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 -");
, (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));
}
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
}
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
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
}
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 ();
}
}
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);
}
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 ("");
}
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
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)
// 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());
#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 :)
, 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;
}
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);
, 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);
, 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;
}
, 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);
}