2 * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef __gtk_ardour_http_h__
20 #define __gtk_ardour_http_h__
22 #include <curl/curl.h>
26 namespace ArdourCurl {
30 HttpGet (bool persist = false, bool ssl = true);
34 MemStruct () : data (0), size (0) {}
40 std::map<std::string, std::string> h;
43 char* get (const char* url);
45 std::string get (const std::string& url) {
46 char *rv = get (url.c_str ());
47 return rv ? std::string (rv) : std::string ("");
50 char* data () const { return mem.data; }
51 size_t data_size () const { return mem.size; }
53 long int status () const { return _status; }
55 std::map<std::string, std::string> header () const { return nfo.h; }
57 char* escape (const char* s, int l) const {
58 return curl_easy_escape (_curl, s, l);
61 char* unescape (const char* s, int l, int *o) const {
62 return curl_easy_unescape (_curl, s, l, o);
65 void free (void *p) const {
69 std::string error () const;
71 CURL* curl () const { return _curl; }
73 // called from fixup_bundle_environment
74 static void setup_certificate_paths ();
83 char error_buffer[CURL_ERROR_SIZE];
86 struct HeaderInfo nfo;
88 static const char* ca_path;
89 static const char* ca_info;
92 char* http_get (const char* url, int* status);
94 std::string http_get (const std::string& url);
98 #endif /* __gtk_ardour_http_h__ */