Project

General

Profile

Actions

Bug #9562

closed

Cannot install gems from gzip-compressing gem server

Added by 5.5 (5 5) over 10 years ago. Updated about 10 years ago.

Status:
Rejected
Target version:
ruby -v:
ruby 2.0.0p353 (2013-11-22) [i386-mingw32]
[ruby-dev:48015]

Description

gem generate_index で作成した gem server が gzip 圧縮を行う場合,Ruby 2.0 以上では gem のインストールに失敗します。

Ruby 1.9 では正常です。

サーバーを gzip 圧縮しない設定にすれば問題が解消します。

Updated by naruse (Yui NARUSE) over 10 years ago

  • Status changed from Open to Assigned
  • Assignee set to drbrain (Eric Hodel)
  • Target version set to 2.2.0
  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN to 1.9.3: DONTNEED, 2.0.0: REQUIRED, 2.1: REQUIRED

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

Updated by drbrain (Eric Hodel) over 10 years ago

  • Status changed from Assigned to Rejected

If the server does not return a gzip Content-Type for a .gz file it is misconfigured. This is not a bug in rubygems.

Updated by knu (Akinori MUSHA) over 10 years ago

Eric, I think the problem is that Gem::RemoteFetcher#fetch_path fails in Gem.gunzip data if the data is already decoded by Net::HTTP of Ruby 2.0 and later.
It happens when the HTTP server is configured to set a Content-Encoding: gzip header for .gz files, which itself is not necessarily a misconfiguration.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0