mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +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;
|
break;
|
||||||
}
|
}
|
||||||
if (request.method != HTTP_GET) {
|
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,
|
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE,
|
||||||
request.raw_data.size());
|
request.raw_data.size());
|
||||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS,
|
curl_easy_setopt(curl, CURLOPT_POSTFIELDS,
|
||||||
request.raw_data.c_str());
|
request.raw_data.c_str());
|
||||||
} else if (!request.fields.empty()) {
|
} else {
|
||||||
std::string str;
|
std::string str;
|
||||||
for (auto &field : request.fields) {
|
for (auto &field : request.fields) {
|
||||||
if (!str.empty())
|
if (!str.empty())
|
||||||
|
@ -314,10 +316,8 @@ HTTPFetchOngoing::HTTPFetchOngoing(const HTTPFetchRequest &request_,
|
||||||
str += "=";
|
str += "=";
|
||||||
str += urlencode(field.second);
|
str += urlencode(field.second);
|
||||||
}
|
}
|
||||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE,
|
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, str.size());
|
||||||
str.size());
|
curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, str.c_str());
|
||||||
curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS,
|
|
||||||
str.c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ struct HTTPFetchRequest
|
||||||
// Fields of the request
|
// Fields of the request
|
||||||
StringMap fields;
|
StringMap fields;
|
||||||
|
|
||||||
// Raw data of the request overrides fields
|
// Raw data of the request (instead of fields)
|
||||||
std::string raw_data;
|
std::string raw_data;
|
||||||
|
|
||||||
// If not empty, should contain entries such as "Accept: text/html"
|
// If not empty, should contain entries such as "Accept: text/html"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue