Project

General

Profile

Actions

Bug #501

closed

rubygems fails to cache spec file

Added by mame (Yusuke Endoh) over 14 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
Normal
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

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0