Skip to content

Commit f52c0b8

Browse files
authored
Merge pull request #341 from ammarfaizi2/fix-curl-netlib
[GIT PULL] net: CurlHttpClient: Call `curl_easy_reset()` to fix error 'rewinding of the data'
2 parents 84e93a1 + 54bc1be commit f52c0b8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/net/CurlHttpClient.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ static CURL* getCurlHandle(const CurlHttpClient *c_) {
2828
if (!curl) {
2929
throw std::runtime_error("curl_easy_init() failed");
3030
}
31-
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 20);
32-
curl_easy_setopt(curl, CURLOPT_TIMEOUT, c->_timeout);
3331
c->curlHandles[id] = curl;
3432
return curl;
3533
}
@@ -45,6 +43,9 @@ static std::size_t curlWriteString(char* ptr, std::size_t size, std::size_t nmem
4543
std::string CurlHttpClient::makeRequest(const Url& url, const std::vector<HttpReqArg>& args) const {
4644
CURL* curl = getCurlHandle(this);
4745

46+
curl_easy_reset(curl);
47+
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 20);
48+
curl_easy_setopt(curl, CURLOPT_TIMEOUT, _timeout);
4849
std::string u = url.protocol + "://" + url.host + url.path;
4950
if (args.empty()) {
5051
u += "?" + url.query;

0 commit comments

Comments
 (0)