Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/libstore/filetransfer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,11 @@ struct curlFileTransfer : public FileTransfer
if (request.method == HttpMethod::POST) {
curl_easy_setopt(req, CURLOPT_POST, 1L);
curl_easy_setopt(req, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t) request.data->length());
} else {
} else if (request.method == HttpMethod::PUT) {
curl_easy_setopt(req, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(req, CURLOPT_INFILESIZE_LARGE, (curl_off_t) request.data->length());
} else {
unreachable();
}
curl_easy_setopt(req, CURLOPT_READFUNCTION, readCallbackWrapper);
curl_easy_setopt(req, CURLOPT_READDATA, this);
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/http-binary-cache-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void HttpBinaryCacheStore::upsertFile(
uint64_t sizeHint)
{
auto req = makeRequest(path);

req.method = HttpMethod::PUT;
auto data = StreamToSourceAdapter(istream).drain();

auto compressionMethod = getCompressionMethod(path);
Expand Down
3 changes: 3 additions & 0 deletions src/libstore/include/nix/store/filetransfer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ extern const unsigned int RETRY_TIME_MS_DEFAULT;
*/
enum struct HttpMethod {
GET,
PUT,
HEAD,
POST,
DELETE,
Expand Down Expand Up @@ -147,7 +148,9 @@ struct FileTransferRequest
case HttpMethod::HEAD:
case HttpMethod::GET:
return "download";
case HttpMethod::PUT:
case HttpMethod::POST:
assert(data);
return "upload";
case HttpMethod::DELETE:
return "delet";
Expand Down
1 change: 1 addition & 0 deletions src/libstore/s3-binary-cache-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ std::string
S3BinaryCacheStore::uploadPart(std::string_view key, std::string_view uploadId, uint64_t partNumber, std::string data)
{
auto req = makeRequest(key);
req.method = HttpMethod::PUT;
req.setupForS3();

auto url = req.uri.parsed();
Expand Down
Loading