diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/connection.cpp | 6 | ||||
-rw-r--r-- | src/curl_wrapper.cpp | 10 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/connection.cpp b/src/connection.cpp index f471c4e..9bc43f0 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -42,4 +42,10 @@ answer_type Connection::get(const endpoint_variant &endpoint, return make_request(http_method::GET, uri, parameters); } +void Connection::set_proxy(const string_view proxy) +{ + CURLWrapper::set_proxy(proxy); + _instance.set_proxy(proxy); +} + } // namespace mastodonpp diff --git a/src/curl_wrapper.cpp b/src/curl_wrapper.cpp index 7b0eb79..0b8b49c 100644 --- a/src/curl_wrapper.cpp +++ b/src/curl_wrapper.cpp @@ -63,6 +63,16 @@ CURLWrapper::~CURLWrapper() noexcept } } +void CURLWrapper::set_proxy(const string_view proxy) +{ + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) + CURLcode code = curl_easy_setopt(_connection, CURLOPT_PROXY, proxy); + if (code != CURLE_OK) + { + throw CURLException{code, "Failed to set proxy", _curl_buffer_error}; + } +} + answer_type CURLWrapper::make_request(const http_method &method, string uri, const parametermap ¶meters) { |