* lib/open-uri.rb (URI::HTTP#proxy_open): set Host: field explicitly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
51ef45c6f3
commit
317547dc5d
@ -1,3 +1,7 @@
|
|||||||
|
Wed Apr 21 20:05:00 2004 Tanaka Akira <akr@m17n.org>
|
||||||
|
|
||||||
|
* lib/open-uri.rb (URI::HTTP#proxy_open): set Host: field explicitly.
|
||||||
|
|
||||||
Wed Apr 21 18:39:46 2004 Minero Aoki <aamine@loveruby.net>
|
Wed Apr 21 18:39:46 2004 Minero Aoki <aamine@loveruby.net>
|
||||||
|
|
||||||
* lib/net/smtp.rb: merge SMTP-TLS patch. This patch is
|
* lib/net/smtp.rb: merge SMTP-TLS patch. This patch is
|
||||||
@ -465,7 +469,7 @@ Sun Mar 28 14:09:13 2004 Minero Aoki <aamine@loveruby.net>
|
|||||||
|
|
||||||
Sat Mar 27 21:40:41 2004 Tanaka Akira <akr@m17n.org>
|
Sat Mar 27 21:40:41 2004 Tanaka Akira <akr@m17n.org>
|
||||||
|
|
||||||
* (lib/open-uri.rb): permit extra semicolon in content-type field.
|
* lib/open-uri.rb: permit extra semicolon in content-type field.
|
||||||
|
|
||||||
Sat Mar 27 10:40:48 2004 Tanaka Akira <akr@m17n.org>
|
Sat Mar 27 10:40:48 2004 Tanaka Akira <akr@m17n.org>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#= open-uri.rb
|
#= open-uri.rb
|
||||||
#
|
#
|
||||||
#open-uri.rb is easy-to-use wrapper for net/http and net/ftp.
|
#open-uri.rb is easy-to-use wrapper for net/http and net/ftp.
|
||||||
#
|
#
|
||||||
#== Example
|
#== Example
|
||||||
#
|
#
|
||||||
#It is possible to open http/ftp URL as usual a file:
|
#It is possible to open http/ftp URL as usual a file:
|
||||||
@ -40,7 +40,7 @@
|
|||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
#URI objects can be opened in similar way.
|
#URI objects can be opened in similar way.
|
||||||
#
|
#
|
||||||
# uri = URI.parse("http://www.ruby-lang.org/en/")
|
# uri = URI.parse("http://www.ruby-lang.org/en/")
|
||||||
# uri.open {|f|
|
# uri.open {|f|
|
||||||
# ...
|
# ...
|
||||||
@ -66,7 +66,7 @@ module Kernel
|
|||||||
# If the first argument respond to `open' method,
|
# If the first argument respond to `open' method,
|
||||||
# the method is called with the rest arguments.
|
# the method is called with the rest arguments.
|
||||||
#
|
#
|
||||||
# If the first argument is a string which begins with xxx://,
|
# If the first argument is a string which begins with xxx://,
|
||||||
# it is parsed by URI.parse. If the parsed object respond to `open' method,
|
# it is parsed by URI.parse. If the parsed object respond to `open' method,
|
||||||
# the method is called with the rest arguments.
|
# the method is called with the rest arguments.
|
||||||
#
|
#
|
||||||
@ -181,7 +181,7 @@ module OpenURI
|
|||||||
end
|
end
|
||||||
uri = redirect
|
uri = redirect
|
||||||
raise "HTTP redirection loop: #{uri}" if uri_set.include? uri.to_s
|
raise "HTTP redirection loop: #{uri}" if uri_set.include? uri.to_s
|
||||||
uri_set[uri.to_s] = true
|
uri_set[uri.to_s] = true
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -529,6 +529,16 @@ module URI
|
|||||||
header = {}
|
header = {}
|
||||||
options.each {|k, v| header[k] = v if String === k }
|
options.each {|k, v| header[k] = v if String === k }
|
||||||
|
|
||||||
|
if uri.respond_to? :host
|
||||||
|
# According to RFC2616 14.23, Host: request-header field should be set
|
||||||
|
# an origin server.
|
||||||
|
# But net/http wrongly set a proxy server if an absolute URI is
|
||||||
|
# specified as a request URI.
|
||||||
|
# So open-uri override it here explicitly.
|
||||||
|
header['host'] = uri.host
|
||||||
|
header['host'] += ":#{uri.port}" if uri.port
|
||||||
|
end
|
||||||
|
|
||||||
require 'net/http'
|
require 'net/http'
|
||||||
resp = nil
|
resp = nil
|
||||||
Net::HTTP.start(self.host, self.port) {|http|
|
Net::HTTP.start(self.host, self.port) {|http|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user