Allow HTTP POST without parameters.

This commit is contained in:
tastytea 2020-01-10 14:33:33 +01:00
parent 108aeea771
commit cb7019a0fd
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07

View File

@ -101,10 +101,17 @@ answer_type CURLWrapper::make_request(const http_method &method, string uri,
}
case http_method::POST:
{
curl_mime *mime{parameters_to_curl_mime(uri, parameters)};
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
code = curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);
if (parameters.empty())
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
code = curl_easy_setopt(_connection, CURLOPT_POST, 1L);
}
else
{
curl_mime *mime{parameters_to_curl_mime(uri, parameters)};
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
code = curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);
}
break;
}