mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/net/http.rb (connect): CONNECT must precede SSL connect. [ruby-dev:23379]
* lib/net/http.rb (HTTP.new): class variables are not inherited now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
97a557bdf9
commit
d4f7c8ccef
2 changed files with 41 additions and 35 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Wed Apr 21 17:23:59 2004 Minero Aoki <aamine@loveruby.net>
|
||||||
|
|
||||||
|
* lib/net/http.rb (HTTP#connect): CONNECT must precede SSL connect.
|
||||||
|
[ruby-dev:23379]
|
||||||
|
|
||||||
|
* lib/net/http.rb (HTTP.new): class variables are not inherited
|
||||||
|
now.
|
||||||
|
|
||||||
Wed Apr 21 15:56:43 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Apr 21 15:56:43 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* lib/test/unit/ui/console/testrunner.rb (test_started): restore $0
|
* lib/test/unit/ui/console/testrunner.rb (test_started): restore $0
|
||||||
|
|
|
@ -214,12 +214,6 @@ module Net # :nodoc:
|
||||||
alias is_version_1_2? version_1_2? #:nodoc:
|
alias is_version_1_2? version_1_2? #:nodoc:
|
||||||
end
|
end
|
||||||
|
|
||||||
def HTTP.setimplversion(obj) #:nodoc:
|
|
||||||
f = @@newimpl
|
|
||||||
obj.instance_eval { @newimpl = f }
|
|
||||||
end
|
|
||||||
private_class_method :setimplversion
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# short cut methods
|
# short cut methods
|
||||||
#
|
#
|
||||||
|
@ -314,7 +308,7 @@ module Net # :nodoc:
|
||||||
80
|
80
|
||||||
end
|
end
|
||||||
|
|
||||||
# The default port to use for HTTPS requests; defaults to 80.
|
# The default port to use for HTTPS requests; defaults to 443.
|
||||||
def HTTP.https_default_port
|
def HTTP.https_default_port
|
||||||
443
|
443
|
||||||
end
|
end
|
||||||
|
@ -323,28 +317,30 @@ module Net # :nodoc:
|
||||||
InternetMessageIO
|
InternetMessageIO
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# creates a new Net::HTTP object and opens its TCP connection and
|
||||||
|
# HTTP session. If the optional block is given, the newly
|
||||||
|
# created Net::HTTP object is passed to it and closed when the
|
||||||
|
# block finishes. In this case, the return value of this method
|
||||||
|
# is the return value of the block. If no block is given, the
|
||||||
|
# return value of this method is the newly created Net::HTTP object
|
||||||
|
# itself, and the caller is responsible for closing it upon completion.
|
||||||
|
def HTTP.start(address, port = nil, p_addr = nil, p_port = nil, p_user = nil, p_pass = nil, &block) # :yield: +http+
|
||||||
|
new(address, port, p_addr, p_port, p_user, p_pass).start(&block)
|
||||||
|
end
|
||||||
|
|
||||||
class << HTTP
|
class << HTTP
|
||||||
# creates a new Net::HTTP object and opens its TCP connection and
|
|
||||||
# HTTP session. If the optional block is given, the newly
|
|
||||||
# created Net::HTTP object is passed to it and closed when the
|
|
||||||
# block finishes. In this case, the return value of this method
|
|
||||||
# is the return value of the block. If no block is given, the
|
|
||||||
# return value of this method is the newly created Net::HTTP object
|
|
||||||
# itself, and the caller is responsible for closing it upon completion.
|
|
||||||
def start(address, port = nil, p_addr = nil, p_port = nil, p_user = nil, p_pass = nil, &block) # :yield: +http+
|
|
||||||
new(address, port, p_addr, p_port, p_user, p_pass).start(&block)
|
|
||||||
end
|
|
||||||
|
|
||||||
alias newobj new
|
alias newobj new
|
||||||
|
end
|
||||||
|
|
||||||
# Creates a new Net::HTTP object.
|
# Creates a new Net::HTTP object.
|
||||||
# If +proxy_addr+ is given, creates an Net::HTTP object with proxy support.
|
# If +proxy_addr+ is given, creates an Net::HTTP object with proxy support.
|
||||||
# This method does not open the TCP connection.
|
# This method does not open the TCP connection.
|
||||||
def new(address, port = nil, p_addr = nil, p_port = nil, p_user = nil, p_pass = nil)
|
def HTTP.new(address, port = nil, p_addr = nil, p_port = nil, p_user = nil, p_pass = nil)
|
||||||
obj = Proxy(p_addr, p_port, p_user, p_pass).newobj(address, port)
|
h = Proxy(p_addr, p_port, p_user, p_pass).newobj(address, port)
|
||||||
setimplversion obj
|
h.instance_eval {
|
||||||
obj
|
@newimpl = ::Net::HTTP.version_1_2?
|
||||||
end
|
}
|
||||||
|
h
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates a new Net::HTTP object for the specified +address+.
|
# Creates a new Net::HTTP object for the specified +address+.
|
||||||
|
@ -458,16 +454,18 @@ module Net # :nodoc:
|
||||||
end
|
end
|
||||||
s = OpenSSL::SSL::SSLSocket.new(s, @ssl_context)
|
s = OpenSSL::SSL::SSLSocket.new(s, @ssl_context)
|
||||||
s.sync_close = true
|
s.sync_close = true
|
||||||
s.connect
|
|
||||||
end
|
end
|
||||||
@socket = BufferedIO.new(s)
|
@socket = BufferedIO.new(s)
|
||||||
@socket.read_timeout = @read_timeout
|
@socket.read_timeout = @read_timeout
|
||||||
@socket.debug_output = @debug_output
|
@socket.debug_output = @debug_output
|
||||||
if use_ssl? and proxy?
|
if use_ssl?
|
||||||
@socket.writeline sprintf('CONNECT %s:%s HTTP/%s',
|
if proxy?
|
||||||
@address, @port, HTTP_VERSION)
|
@socket.writeline sprintf('CONNECT %s:%s HTTP/%s',
|
||||||
@socket.writeline ''
|
@address, @port, HTTPVersion)
|
||||||
HTTPResponse.read_new(@socket).value
|
@socket.writeline ''
|
||||||
|
HTTPResponse.read_new(@socket).value
|
||||||
|
end
|
||||||
|
s.connect
|
||||||
end
|
end
|
||||||
on_connect
|
on_connect
|
||||||
end
|
end
|
||||||
|
@ -547,7 +545,7 @@ module Net # :nodoc:
|
||||||
attr_reader :proxy_pass
|
attr_reader :proxy_pass
|
||||||
end
|
end
|
||||||
|
|
||||||
# True if self is a HTTP proxy class
|
# True if self is a HTTP proxy class.
|
||||||
def proxy?
|
def proxy?
|
||||||
self.class.proxy_class?
|
self.class.proxy_class?
|
||||||
end
|
end
|
||||||
|
@ -580,11 +578,11 @@ module Net # :nodoc:
|
||||||
# without proxy
|
# without proxy
|
||||||
|
|
||||||
def conn_address
|
def conn_address
|
||||||
address
|
address()
|
||||||
end
|
end
|
||||||
|
|
||||||
def conn_port
|
def conn_port
|
||||||
port
|
port()
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit_path(path)
|
def edit_path(path)
|
||||||
|
|
Loading…
Reference in a new issue