diff options
author | Matthew Bauer <mjbauer95@gmail.com> | 2021-01-22 14:46:40 -0600 |
---|---|---|
committer | Matthew Bauer <mjbauer95@gmail.com> | 2021-01-22 14:47:45 -0600 |
commit | a76682466062ef2c972d19f259feeef1c46a44a3 (patch) | |
tree | bfcc65c6fb101d177699f53df15ff0f07188ce7f | |
parent | b7bfc7ee52dd425e0156f369eb4c05a62358f912 (diff) |
Handle missing etag in 304 Not Modified response
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 #4469
-rw-r--r-- | src/libstore/filetransfer.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc index 31b4215a9..1b7eae3ec 100644 --- a/src/libstore/filetransfer.cc +++ b/src/libstore/filetransfer.cc @@ -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)); |