Repository navigation
Filter gzipped gem compact indexes under cooldown - #584
Merged
Merged
Conversation
With cooldown on, /info/{name} is fetched from upstream and versions still in cooldown are removed line by line. The fetch passed on the client's Accept-Encoding, and setting that header turns off the transport's transparent decompression, so for any client that accepts gzip, Bundler included, the filter scanned gzip bytes, matched no versions and sent the compressed index on with upstream's Content-Encoding. Cooldown filtered nothing for those clients.
The fetch now passes on only Accept, so the transport decompresses the index before it is filtered. If-None-Match and If-Modified-Since are no longer passed on either: the client's validators came from a filtered copy, not from upstream's file.
The filtered index no longer carries upstream's ETag, Last-Modified, Digest, Repr-Digest or range headers, which describe the unfiltered file; Bundler checks the digest against the body it gets.
The index is now read through ReadMetadata before anything is written. bufio.Scanner stopped at a line over 64 KB and the handler sent what it had so far as a complete 200; a read error or an index over the metadata size limit now answers 502.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With cooldown on, the gem handler fetches
/info/{name}from upstream and drops the lines of versions still in cooldown. The fetch passed on the client'sAccept-Encoding, and setting that header turns off Go's transparent decompression, so for any client that accepts gzip (Bundler does by default) the filter scanned gzip bytes, matched nothing, and sent the compressed index on with upstream'sContent-Encoding. Cooldown filtered nothing for Bundler.Accept, so the transport decompresses the index before it is filtered. The client'sIf-None-Match/If-Modified-Sinceare no longer sent upstream either, since they belong to the filtered copy.ETag,Last-Modified,Digest,Repr-Digestand range headers, which describe the unfiltered file. Bundler checks the digest against the body it receives.ReadMetadatabefore anything is written.bufio.Scannerstopped at a line over 64 KB and the handler sent what it had as a complete 200; a read error or an index over the metadata size limit now gets a 502.The other handlers that pass
Accept-Encodingupstream (npm search/keys/audit, NuGet, Conda, CRAN, gem API passthrough) relay the body unchanged, and Conda's repodata filter already decompresses itself, so they're left as they are.Tests:
TestGemCompactIndexCooldownClientAcceptsGzip,TestGemCompactIndexCooldownLongLine,TestGemCompactIndexCooldownOversizedIndex.