Add vector fields to HTTP forms.

This commit is contained in:
tastytea 2020-01-10 14:24:35 +01:00
parent 89c50951b3
commit 1910e780b0
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 12 additions and 6 deletions

View File

@ -325,15 +325,15 @@ curl_mime *CURLWrapper::parameters_to_curl_mime(string &uri,
continue;
}
curl_mimepart *part{curl_mime_addpart(mime)};
if (part == nullptr)
{
throw CURLException{"Could not build HTTP form."};
}
CURLcode code;
if (holds_alternative<string_view>(param.second))
{
curl_mimepart *part{curl_mime_addpart(mime)};
if (part == nullptr)
{
throw CURLException{"Could not build HTTP form."};
}
code = curl_mime_name(part, param.first.data());
if (code != CURLE_OK)
{
@ -353,6 +353,12 @@ curl_mime *CURLWrapper::parameters_to_curl_mime(string &uri,
{
for (const auto &arg : get<vector<string_view>>(param.second))
{
curl_mimepart *part{curl_mime_addpart(mime)};
if (part == nullptr)
{
throw CURLException{"Could not build HTTP form."};
}
const string name{string(param.first) += "[]"};
code = curl_mime_name(part, name.c_str());
if (code != CURLE_OK)