Skip to content

Commit

Permalink
Handle missing etag in 304 Not Modified response
Browse files Browse the repository at this point in the history
GitHub now omits the etag, but 304 implies it matches the one we
provided. Just use that one to avoid having an etag-less resource.

Fixes NixOS#4469
  • Loading branch information
matthewbauer committed Jan 22, 2021
1 parent b7bfc7e commit a766824
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/libstore/filetransfer.cc
Expand Up @@ -375,6 +375,13 @@ struct curlFileTransfer : public FileTransfer
else if (code == CURLE_OK && successfulStatuses.count(httpStatus))
{
result.cached = httpStatus == 304;

// In 2021, GitHub responds to If-None-Match with 304,
// but omits ETag. We just use the If-None-Match etag
// since 304 implies they are the same.
if (httpStatus == 304 && result.etag == "")
result.etag = request.expectedETag;

act.progress(result.bodySize, result.bodySize);
done = true;
callback(std::move(result));
Expand Down

0 comments on commit a766824

Please sign in to comment.