lib/curl/Request: add constructor without "url" parameter
Allows constructing the request first and set the URL later. This is needed because curl_easy_escape() is needed to construct the URL, which however needs the CURL "easy" handle created by the Request class.
This commit is contained in:
parent
96676f8f3b
commit
74eac1d449
@ -45,7 +45,7 @@
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
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
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user