Bug #501

rubygems fails to cache spec file

Added by Yusuke Endoh over 6 years ago. Updated almost 4 years ago.

[ruby-core:18387]
Status:Closed
Priority:Low
Assignee:Eric Hodel
ruby -v: Backport:

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
  •  return ""
    

    when Net::HTTPRedirection then
    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

History

#1 Updated by Yusuke Endoh over 6 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

#2 Updated by Eric Hodel over 6 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

#3 Updated by Koichi Sasada over 6 years ago

  • Assignee set to Eric Hodel

=begin

=end

#4 Updated by Yuki Sonoda over 6 years ago

  • Target version set to 1.9.1 Release Candidate

=begin

=end

#5 Updated by Yuki Sonoda over 6 years ago

  • Due date set to 11/25/2008
  • Category set to lib

=begin

=end

#6 Updated by Yuki Sonoda about 6 years ago

=begin
I'll ask Eric whether it has already been merged.
=end

#7 Updated by Eric Hodel about 6 years ago

  • Status changed from Open to Closed

=begin
This has been fixed and merged.
=end

Also available in: Atom PDF