mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
fix(libstore): use CURLOPT_POSTFIELDSIZE_LARGE for POST requests
Fix POST requests with data to use the correct curl option for specifying body size. Previously used CURLOPT_INFILESIZE_LARGE for both POST and PUT, but POST requires CURLOPT_POSTFIELDSIZE_LARGE. This caused POST request bodies to not be sent correctly, manifesting as S3 multipart CompleteMultipartUpload requests failing with "You must specify at least one part" even though the XML body contained valid parts.
This commit is contained in:
parent
115dea10b2
commit
953929f899
1 changed files with 5 additions and 3 deletions
|
|
@ -388,13 +388,15 @@ struct curlFileTransfer : public FileTransfer
|
|||
curl_easy_setopt(req, CURLOPT_NOBODY, 1);
|
||||
|
||||
if (request.data) {
|
||||
if (request.post)
|
||||
if (request.post) {
|
||||
curl_easy_setopt(req, CURLOPT_POST, 1L);
|
||||
else
|
||||
curl_easy_setopt(req, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t) request.data->length());
|
||||
} else {
|
||||
curl_easy_setopt(req, CURLOPT_UPLOAD, 1L);
|
||||
curl_easy_setopt(req, CURLOPT_INFILESIZE_LARGE, (curl_off_t) request.data->length());
|
||||
}
|
||||
curl_easy_setopt(req, CURLOPT_READFUNCTION, readCallbackWrapper);
|
||||
curl_easy_setopt(req, CURLOPT_READDATA, this);
|
||||
curl_easy_setopt(req, CURLOPT_INFILESIZE_LARGE, (curl_off_t) request.data->length());
|
||||
curl_easy_setopt(req, CURLOPT_SEEKFUNCTION, seekCallbackWrapper);
|
||||
curl_easy_setopt(req, CURLOPT_SEEKDATA, this);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue