Bug #501
closedrubygems fails to cache spec file
Description
=begin
Hi,
I realized "gem update" always fetched the whole spec file
from gems.rubyforge.org even if rubygems has cache.
rubygems certainly sends If-Modified-Since field to the
server. But the rubyforge server ignores it.
I confirmed this by using WEBrick::HTTPProxyServer.
This is because Apache, which rubyforge uses, seems to handle
If-Modified-Since field only when it is represented in GMT.
This is not a fault of rubygems, but I think it's better for
rubygems to convert last_modified in GMT.
In addition, I noticed rubygems fails to handle "304 Not
Modified" response.
$ gem update
Updating installed gems
ERROR: While executing gem ... (URI::InvalidURIError)
bad URI(is not URI?):
I think this is a problem of rubygems.
users who live in GMT should know this bug, but I cannot¶
find any report and complaint... How come? :-(¶
Here is a patch.
Index: lib/rubygems/remote_fetcher.rb¶
--- lib/rubygems/remote_fetcher.rb (revision 18876)
+++ lib/rubygems/remote_fetcher.rb (working copy)
@@ -140,6 +140,7 @@
def fetch_path(uri, mtime = nil, head = false)
data = open_uri_or_path(uri, mtime, head)
- return data if data.empty?
data = Gem.gunzip data if uri.to_s =~ /gz$/ and not head
data
rescue FetchError
@@ -243,6 +244,8 @@
case response
when Net::HTTPOK then
head ? response : response.body - when Net::HTTPNotModified then
-
when Net::HTTPRedirection thenreturn ""
raise FetchError.new('too many redirects', uri) if depth > 10
@@ -274,7 +277,7 @@
request.add_field 'Keep-Alive', '30'
if last_modified then
-
request.add_field 'If-Modified-Since', last_modified.rfc2822
-
request.add_field 'If-Modified-Since', last_modified.dup.gmtime.rfc2822
end
connection = connection_for uri
--
Yusuke ENDOH mame@tsg.ne.jp
=end
Updated by mame (Yusuke Endoh) about 16 years ago
=begin
Hi,
2008/8/27 Tanaka Akira akr@fsij.org:
This is because Apache, which rubyforge uses, seems to handle
If-Modified-Since field only when it is represented in GMT.
This is not a fault of rubygems, but I think it's better for
rubygems to convert last_modified in GMT.See HTTP-date definition of RFC 2616.
Aha, this is a fault of rubygems X-(
--
Yusuke ENDOH mame@tsg.ne.jp
=end
Updated by drbrain (Eric Hodel) about 16 years ago
=begin
On Aug 26, 2008, at 10:13 AM, Yusuke ENDOH wrote:
2008/8/27 Tanaka Akira akr@fsij.org:
This is because Apache, which rubyforge uses, seems to handle
If-Modified-Since field only when it is represented in GMT.
This is not a fault of rubygems, but I think it's better for
rubygems to convert last_modified in GMT.See HTTP-date definition of RFC 2616.
Aha, this is a fault of rubygems X-(
I already fixed this in RubyGems trunk, but haven't got RubyGems
stable enough to merge.
=end
Updated by yugui (Yuki Sonoda) about 16 years ago
- Target version set to 1.9.1 Release Candidate
=begin
=end
Updated by yugui (Yuki Sonoda) about 16 years ago
- Due date set to 11/25/2008
- Category set to lib
=begin
=end
Updated by yugui (Yuki Sonoda) almost 16 years ago
=begin
I'll ask Eric whether it has already been merged.
=end
Updated by drbrain (Eric Hodel) almost 16 years ago
- Status changed from Open to Closed
=begin
This has been fixed and merged.
=end