diff --git a/src/lib/curl/Request.cxx b/src/lib/curl/Request.cxx index 204ee7d5b..1b8bbd640 100644 --- a/src/lib/curl/Request.cxx +++ b/src/lib/curl/Request.cxx @@ -45,7 +45,7 @@ #include #include -CurlRequest::CurlRequest(CurlGlobal &_global, const char *url, +CurlRequest::CurlRequest(CurlGlobal &_global, CurlResponseHandler &_handler) :global(_global), handler(_handler), postpone_error_event(global.GetEventLoop(), @@ -64,7 +64,6 @@ CurlRequest::CurlRequest(CurlGlobal &_global, const char *url, easy.SetOption(CURLOPT_NOPROGRESS, 1l); easy.SetOption(CURLOPT_NOSIGNAL, 1l); easy.SetOption(CURLOPT_CONNECTTIMEOUT, 10l); - easy.SetOption(CURLOPT_URL, url); } CurlRequest::~CurlRequest() noexcept diff --git a/src/lib/curl/Request.hxx b/src/lib/curl/Request.hxx index a54c7c575..40abfbf6b 100644 --- a/src/lib/curl/Request.hxx +++ b/src/lib/curl/Request.hxx @@ -78,8 +78,15 @@ public: /** * To start sending the request, call Start(). */ - CurlRequest(CurlGlobal &_global, const char *url, + CurlRequest(CurlGlobal &_global, CurlResponseHandler &_handler); + + CurlRequest(CurlGlobal &_global, const char *url, + CurlResponseHandler &_handler) + :CurlRequest(_global, _handler) { + SetUrl(url); + } + ~CurlRequest() noexcept; CurlRequest(const CurlRequest &) = delete; @@ -119,6 +126,10 @@ public: easy.SetOption(option, value); } + void SetUrl(const char *url) { + easy.SetOption(CURLOPT_URL, url); + } + /** * CurlResponseHandler::OnData() shall throw this to pause the * stream. Call Resume() to resume the transfer.