summaryrefslogtreecommitdiff
path: root/src/other_tools/utils/curl_url_handle.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/other_tools/utils/curl_url_handle.hpp')
-rw-r--r--src/other_tools/utils/curl_url_handle.hpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/other_tools/utils/curl_url_handle.hpp b/src/other_tools/utils/curl_url_handle.hpp
index dfd278d7..5648a535 100644
--- a/src/other_tools/utils/curl_url_handle.hpp
+++ b/src/other_tools/utils/curl_url_handle.hpp
@@ -154,6 +154,17 @@ class CurlURLHandle {
[[nodiscard]] auto NoproxyStringMatches(
std::string const& no_proxy) noexcept -> std::optional<bool>;
+ /// \brief Tries to replace the hostname of a given URL. This is done by
+ /// parsing the URL with minimal validity checks, replacing the original
+ /// hostname with the one given, then putting the new URL back together.
+ /// \note The given URL MUST have a hostname for this to succeed.
+ /// \note A missing scheme field will be set to "https://" and a missing
+ /// path field will be set to "/".
+ /// \returns The new URL or nullopt on errors. This method is never fatal.
+ [[nodiscard]] static auto ReplaceHostname(
+ std::string const& url,
+ std::string const& hostname) noexcept -> std::optional<std::string>;
+
private:
// IMPORTANT: the CurlContext must be initialized before any curl
// object!