From: Chad Fowler Date: 2004-05-04T07:36:08+09:00 Subject: Re: open-uri BUG? (was rubygem BUG) --Apple-Mail-1-89863995 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed On 3/5/2004, at 2:19 AM, Mehr, Assaph (Assaph) wrote: > >> I suppose the rubyforge bug report is most appropriate, but I don't > mind >> where it's reported, as long as I find out :) > > So here's another one for you: --http-proxy seems to ignore the port. > gem -P http://proxy:8000 -l (and variations) barf up with: > > *** REMOTE GEMS *** > c:/langs/ruby/lib/ruby/1.8/open-uri.rb:544:in `proxy_open': 404 Not > Found (OpenURI::HTTPError) > from c:/langs/ruby/lib/ruby/1.8/open-uri.rb:167:in `open_loop' > from c:/langs/ruby/lib/ruby/1.8/open-uri.rb:164:in `catch' > from c:/langs/ruby/lib/ruby/1.8/open-uri.rb:164:in `open_loop' > from c:/langs/ruby/lib/ruby/1.8/open-uri.rb:134:in `open_uri' > from c:/langs/ruby/lib/ruby/1.8/open-uri.rb:422:in `open' > from c:/langs/ruby/lib/ruby/1.8/open-uri.rb:85:in `open' > from > (snipped) I didn't get a chance to finish today, but at this point, it looks like there is a small bug in the open-uri.rb library. Specifically, the bug appears to be in URI::HTTP.proxy_open where the following happens: require 'net/http' resp = nil Net::HTTP.start(self.host, self.port) {|http| ^^^^^^^ The value here ends up getting set in the "Host" HTTP header. This means "Host" gets set to the *proxy* host, which is not correct. From the HTTP 1.1 RFC (RFC 2616)[1] The Host request-header field specifies the Internet host and port number of the resource being requested, as obtained from the original URI given by the user or referring resource... In the open-uri library, the *resource being requested* is not the proxy server, but that's what is getting set in the "Host" header. I will try to make a patch over the next couple of days, but I'm traveling (again) and will have limited time. Chad [1]http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23 --Apple-Mail-1-89863995--