From 257d7ffa7b3d1f12e76895231d79acbc2d7a696d Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Mon, 22 Apr 2024 21:03:02 +0200 Subject: libstore: remove github etag workaround MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this was a workaround for a *github* bug that happend *in 2015*. not only is github no longer buggy, it shouldn't have been nix's responsibility to work around these bugs like this to begin with while we're at it we'll also remove another workaround—again for github specifically and again for etag handling—from 2021 that's also not needed any more. future workarounds for serverside bugs should probably come with an expiration date that mutates into a build warning after a while, otherwise this *will* happen again. Change-Id: I74f739ae3e36d40350f78bebcb5869aa8cc9adcd --- src/libstore/filetransfer.cc | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'src/libstore/filetransfer.cc') diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc index 7d36796f4..adbeb58ca 100644 --- a/src/libstore/filetransfer.cc +++ b/src/libstore/filetransfer.cc @@ -204,17 +204,6 @@ struct curlFileTransfer : public FileTransfer if (name == "etag") { result.etag = trim(line.substr(i + 1)); - /* Hack to work around a GitHub bug: it sends - ETags, but ignores If-None-Match. So if we get - the expected ETag on a 200 response, then shut - down the connection because we already have the - data. */ - long httpStatus = 0; - curl_easy_getinfo(req, CURLINFO_RESPONSE_CODE, &httpStatus); - if (result.etag == request.expectedETag && httpStatus == 200) { - debug("shutting down on 200 HTTP response with expected ETag"); - return 0; - } } else if (name == "content-encoding") @@ -375,24 +364,12 @@ struct curlFileTransfer : public FileTransfer } } - if (code == CURLE_WRITE_ERROR && result.etag == request.expectedETag) { - code = CURLE_OK; - httpStatus = 304; - } - if (writeException) failEx(writeException); 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)); -- cgit v1.2.3