Project

General

Profile

Actions

Bug #501

closed

rubygems fails to cache spec file

Added by mame (Yusuke Endoh) over 15 years ago. Updated almost 13 years ago.

Status:
Closed
ruby -v:
Backport:
[ruby-core:18387]

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
=end

Actions #1

Updated by mame (Yusuke Endoh) over 15 years ago

=begin
Hi,

2008/8/27 Tanaka Akira :

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

=end

Actions #2

Updated by drbrain (Eric Hodel) over 15 years ago

=begin
On Aug 26, 2008, at 10:13 AM, Yusuke ENDOH wrote:

2008/8/27 Tanaka Akira :

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

Actions #3

Updated by ko1 (Koichi Sasada) over 15 years ago

  • Assignee set to drbrain (Eric Hodel)

=begin

=end

Actions #4

Updated by yugui (Yuki Sonoda) over 15 years ago

  • Target version set to 1.9.1 Release Candidate

=begin

=end

Actions #5

Updated by yugui (Yuki Sonoda) over 15 years ago

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

=begin

=end

Actions #6

Updated by yugui (Yuki Sonoda) over 15 years ago

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

Actions #7

Updated by drbrain (Eric Hodel) over 15 years ago

  • Status changed from Open to Closed

=begin
This has been fixed and merged.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0