mirror of
https://github.com/NixOS/nix.git
synced 2024-11-23 07:12:27 +00:00
Merge pull request #4470 from matthewbauer/fix-4469
Handle missing etag in 304 Not Modified response
This commit is contained in:
commit
c5b42c5a42
@ -64,7 +64,6 @@ DownloadFileResult downloadFile(
|
|||||||
|
|
||||||
if (res.cached) {
|
if (res.cached) {
|
||||||
assert(cached);
|
assert(cached);
|
||||||
assert(request.expectedETag == res.etag);
|
|
||||||
storePath = std::move(cached->storePath);
|
storePath = std::move(cached->storePath);
|
||||||
} else {
|
} else {
|
||||||
StringSink sink;
|
StringSink sink;
|
||||||
|
@ -375,6 +375,13 @@ struct curlFileTransfer : public FileTransfer
|
|||||||
else if (code == CURLE_OK && successfulStatuses.count(httpStatus))
|
else if (code == CURLE_OK && successfulStatuses.count(httpStatus))
|
||||||
{
|
{
|
||||||
result.cached = httpStatus == 304;
|
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);
|
act.progress(result.bodySize, result.bodySize);
|
||||||
done = true;
|
done = true;
|
||||||
callback(std::move(result));
|
callback(std::move(result));
|
||||||
|
Loading…
Reference in New Issue
Block a user