summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGiovanni Tirloni <gtirloni@tirloni.net>2026-01-27 15:04:30 -0300
committergit <svn-admin@ruby-lang.org>2026-02-04 09:50:27 +0000
commit1258992bdff8818d3ce868e98ccc3496069d996d (patch)
tree7614b7a4bd2d2e129ef2f3dea6d7cf4f585230c6 /lib
parent9cc2242ee269fcb4d1fd10887a8270c59eb161fc (diff)
[ruby/rubygems] Fix gzip cache corruption when recovering from HTTP 416 responses
When a Range request returns 416 (Range Not Satisfiable), the recovery path manually added an "Accept-Encoding: gzip" header before retrying. This bypasses Ruby's automatic gzip decompression mechanism. Ruby's Net::HTTP only sets decode_content=true (enabling automatic decompression) when Accept-Encoding is NOT present in the request headers. By manually setting this header, the decode_content flag remained false, causing gzip-compressed response bodies to be written directly to the compact index cache without decompression. This resulted in "ArgumentError: invalid byte sequence in UTF-8" errors when the corrupted cache was later read and parsed as text. The fix removes the explicit Accept-Encoding header, allowing Ruby's Net::HTTP to handle gzip compression transparently (as it does for all other requests). Ruby will still add Accept-Encoding: gzip automatically AND properly set decode_content=true for automatic decompression. Fixes https://github.com/ruby/rubygems/pull/9271 https://github.com/ruby/rubygems/commit/b48b090e38
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/fetcher/downloader.rb1
1 files changed, 0 insertions, 1 deletions
diff --git a/lib/bundler/fetcher/downloader.rb b/lib/bundler/fetcher/downloader.rb
index 2eac6e7975..179eed8340 100644
--- a/lib/bundler/fetcher/downloader.rb
+++ b/lib/bundler/fetcher/downloader.rb
@@ -54,7 +54,6 @@ module Bundler
when Gem::Net::HTTPRequestedRangeNotSatisfiable
new_headers = headers.dup
new_headers.delete("Range")
- new_headers["Accept-Encoding"] = "gzip"
fetch(uri, new_headers)
when Gem::Net::HTTPRequestEntityTooLarge
raise FallbackError, response.body