You know, since Ruby 2.0.0, net/http automatically decode content-encoding;gzip.
Therefore Gem::Request, which uses Net::HTTP internally, also decode gz file, for example specs.4.8.gz,
if a gemsource server sets Content-Encoding: gzip to gz files.
Individual gem servers may hit this issue if people accidentally set Content-Encoding: gzip.
I think this issue should be avoided by RubyGems, and a patch may be following:
diff --git a/lib/rubygems/request.rb b/lib/rubygems/request.rb
index d2f076f..588dae4 100644
--- a/lib/rubygems/request.rb
+++ b/lib/rubygems/request.rb
@@ -112,6 +112,7 @@ class Gem::Request
request.add_field 'User-Agent', @user_agent
request.add_field 'Connection', 'keep-alive'
request.add_field 'Keep-Alive', '30'
+ request.add_field 'Accept-Encoding', ''
if @last_modified then
request.add_field 'If-Modified-Since', @last_modified.httpdate