mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +00:00
Fix PUT and DELETE requests without data
This commit is contained in:
parent
01e4395977
commit
4164cea58f
2 changed files with 7 additions and 7 deletions
|
@ -300,12 +300,14 @@ HTTPFetchOngoing::HTTPFetchOngoing(const HTTPFetchRequest &request_,
|
|||
break;
|
||||
}
|
||||
if (request.method != HTTP_GET) {
|
||||
if (!request.raw_data.empty()) {
|
||||
if (request.fields.empty()) {
|
||||
// Note that we need to set this to an empty buffer (not NULL)
|
||||
// even if no data is to be sent.
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE,
|
||||
request.raw_data.size());
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS,
|
||||
request.raw_data.c_str());
|
||||
} else if (!request.fields.empty()) {
|
||||
} else {
|
||||
std::string str;
|
||||
for (auto &field : request.fields) {
|
||||
if (!str.empty())
|
||||
|
@ -314,10 +316,8 @@ HTTPFetchOngoing::HTTPFetchOngoing(const HTTPFetchRequest &request_,
|
|||
str += "=";
|
||||
str += urlencode(field.second);
|
||||
}
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE,
|
||||
str.size());
|
||||
curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS,
|
||||
str.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, str.size());
|
||||
curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, str.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue