From 194e729b290d6607245b19fadf1bfb92bdcbaed4 Mon Sep 17 00:00:00 2001 From: tastytea Date: Fri, 13 Nov 2020 18:18:22 +0100 Subject: [PATCH] Add set_proxy(). --- src/curl_wrapper.cpp | 6 ++++++ src/curl_wrapper.hpp | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/curl_wrapper.cpp b/src/curl_wrapper.cpp index cbc47ad..c41de33 100644 --- a/src/curl_wrapper.cpp +++ b/src/curl_wrapper.cpp @@ -83,6 +83,12 @@ void CURLWrapper::set_useragent(string_view useragent) check(curl_easy_setopt(_connection, CURLOPT_USERAGENT, useragent.data())); } +void CURLWrapper::set_proxy(const string_view proxy) +{ + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) + check(curl_easy_setopt(_connection, CURLOPT_PROXY, proxy.data())); +} + answer CURLWrapper::make_http_request(http_method method, string_view uri) { _buffer_headers.clear(); diff --git a/src/curl_wrapper.hpp b/src/curl_wrapper.hpp index 95b9b7c..ee5a059 100644 --- a/src/curl_wrapper.hpp +++ b/src/curl_wrapper.hpp @@ -154,6 +154,18 @@ public: */ void set_useragent(string_view useragent); + /*! + * @brief Set a proxy. + * + * For more information consult [CURLOPT_PROXY(3)] + * (https://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html). + * + * May throw CURLException. + * + * @since 0.1.1 + */ + inline void set_proxy(string_view proxy); + /*! * @brief Make a HTTP request. *