diff --git a/src/curl_wrapper.cpp b/src/curl_wrapper.cpp index c28ee7c..a981b83 100644 --- a/src/curl_wrapper.cpp +++ b/src/curl_wrapper.cpp @@ -77,7 +77,25 @@ CURLWrapper::~CURLWrapper() noexcept } } -void CURLWrapper::set_useragent(string_view useragent) +string CURLWrapper::escape_url(const string_view url) const +{ + char *cbuf{curl_easy_escape(_connection, url.data(), + static_cast(url.size()))}; + string sbuf{cbuf}; + curl_free(cbuf); + return sbuf; +} + +string CURLWrapper::unescape_url(const string_view url) const +{ + char *cbuf{curl_easy_unescape(_connection, url.data(), + static_cast(url.size()), nullptr)}; + string sbuf{cbuf}; + curl_free(cbuf); + return sbuf; +} + +void CURLWrapper::set_useragent(const string_view useragent) { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) check(curl_easy_setopt(_connection, CURLOPT_USERAGENT, useragent.data())); diff --git a/src/curl_wrapper.hpp b/src/curl_wrapper.hpp index 569da87..7dbc738 100644 --- a/src/curl_wrapper.hpp +++ b/src/curl_wrapper.hpp @@ -103,14 +103,7 @@ public: * * @since 0.1.0 */ - [[nodiscard]] inline string escape_url(const string_view url) const - { - char *cbuf{curl_easy_escape(_connection, url.data(), - static_cast(url.size()))}; - string sbuf{cbuf}; - curl_free(cbuf); - return sbuf; - } + [[nodiscard]] string escape_url(string_view url) const; /*! * @brief URL decodes the given string. @@ -124,14 +117,7 @@ public: * * @since 0.1.0 */ - [[nodiscard]] inline string unescape_url(const string_view url) const - { - char *cbuf{curl_easy_unescape(_connection, url.data(), - static_cast(url.size()), nullptr)}; - string sbuf{cbuf}; - curl_free(cbuf); - return sbuf; - } + [[nodiscard]] string unescape_url(string_view url) const; /*! * @brief Set the User-Agent. @@ -152,7 +138,7 @@ public: * * @since 0.1.1 */ - inline void set_proxy(string_view proxy); + void set_proxy(string_view proxy); /*! * @brief Make a HTTP request. @@ -169,7 +155,7 @@ public: [[nodiscard]] answer make_http_request(http_method method, string_view uri); private: - CURL *_connection; + CURL *_connection{}; char _buffer_error[CURL_ERROR_SIZE]{}; string _buffer_headers; string _buffer_body;