summaryrefslogtreecommitdiff
path: root/gtk2_ardour/ardour_http.h
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-07-18 16:45:45 +0200
committerRobin Gareus <robin@gareus.org>2016-07-18 16:46:59 +0200
commit004b57e9f67c6b818357759005c8e53b041dead4 (patch)
tree59f6b6309d18bc62bd3a3fa2c455574259e5b80e /gtk2_ardour/ardour_http.h
parent1dcb54ba22fc84883512ac332cd45e14b5bf9e1b (diff)
ArdourCurl: prepare to unify various curl calls
mainly motivated by a central location to setup SSL.
Diffstat (limited to 'gtk2_ardour/ardour_http.h')
-rw-r--r--gtk2_ardour/ardour_http.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/gtk2_ardour/ardour_http.h b/gtk2_ardour/ardour_http.h
new file mode 100644
index 0000000000..cabcb3d5bc
--- /dev/null
+++ b/gtk2_ardour/ardour_http.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __gtk_ardour_http_h__
+#define __gtk_ardour_http_h__
+
+#include <curl/curl.h>
+#include <string>
+
+namespace ArdourCurl {
+
+class HttpGet {
+ public:
+ HttpGet (bool persist = false, bool ssl = true);
+ ~HttpGet ();
+
+ struct MemStruct {
+ MemStruct () : data (0), size (0) {}
+ char* data;
+ size_t size;
+ };
+
+ char* get (const char* url);
+
+ std::string get (const std::string& url) {
+ char *rv = get (url.c_str ());
+ return rv ? std::string (rv) : std::string ();
+ }
+
+ char* data () const { return mem.data; }
+ size_t data_size () const { return mem.size; }
+
+ long int status () const { return _status; }
+
+ char* escape (const char* s, int l) const {
+ return curl_easy_escape (_curl, s, l);
+ }
+
+ char* unescape (const char* s, int l, int *o) const {
+ return curl_easy_unescape (_curl, s, l, o);
+ }
+
+ void free (void *p) const {
+ curl_free (p);
+ }
+
+ std::string error () const;
+
+ CURL* curl () const { return _curl; }
+
+ // called from fixup_bundle_environment
+ static void setup_certificate_paths ();
+
+ private:
+ CURL* _curl;
+ bool persist;
+
+ long int _status;
+ long int _result;
+
+ char error_buffer[CURL_ERROR_SIZE];
+
+ struct MemStruct mem;
+
+ static const char* ca_path;
+ static const char* ca_info;
+};
+
+char* http_get (const char* url, int* status);
+
+std::string http_get (const std::string& url);
+
+} // namespace
+
+#endif /* __gtk_ardour_http_h__ */