1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
* lib/net/http.rb: HTTP.Proxy should use self for proxy-class's super class.
* lib/net/http.rb: initialize HTTP.proxy_port by HTTP.port.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
aamine 2002-02-07 20:22:39 +00:00
parent 96a172e701
commit ffc3c4b401
3 changed files with 64 additions and 45 deletions

View file

@ -1,3 +1,10 @@
Fri Feb 8 05:31:48 2002 Minero Aoki <aamine@loveruby.net>
* lib/net/http.rb: HTTP.Proxy should use self for proxy-class's
super class.
* lib/net/http.rb: initialize HTTP.proxy_port by HTTP.port.
Thu Feb 07 13:44:08 2002 akira yamada <akira@arika.org> Thu Feb 07 13:44:08 2002 akira yamada <akira@arika.org>
* uri/common.rb (URI::join): new method. * uri/common.rb (URI::join): new method.

View file

@ -453,7 +453,32 @@ module Net
class HTTP < Protocol class HTTP < Protocol
HTTPVersion = '1.1' #
# constructors
#
class << self
def start( address, port = nil, p_addr = nil, p_port = nil, &block )
new( address, port, p_addr, p_port ).start( &block )
end
alias newobj new
def new( address, port = nil, p_addr = nil, p_port = nil )
obj = Proxy(p_addr, p_port).newobj(address, port)
setimplversion obj
obj
end
end
def initialize( addr, port = nil )
super
@curr_http_version = HTTPVersion
@seems_1_0_server = false
end
# #
# connection # connection
@ -461,11 +486,7 @@ module Net
protocol_param :port, '80' protocol_param :port, '80'
def initialize( addr, port = nil ) HTTPVersion = '1.1'
super
@curr_http_version = HTTPVersion
@seems_1_0_server = false
end
private private
@ -506,26 +527,19 @@ module Net
public public
class << self class << self
def Proxy( p_addr, p_port = nil ) def Proxy( p_addr, p_port = nil )
if p_addr then p_addr or return self
ProxyMod.create_proxy_class( p_addr, p_port || self.port )
else
self
end
end
alias orig_new new p_port ||= port()
mod = ProxyDelta
def new( address, port = nil, p_addr = nil, p_port = nil ) proxyclass = Class.new(self)
c = p_addr ? self::Proxy(p_addr, p_port) : self proxyclass.module_eval {
i = c.orig_new( address, port ) include mod
setimplversion i @is_proxy_class = true
i @proxy_address = p_addr
end @proxy_port = p_port
}
def start( address, port = nil, p_addr = nil, p_port = nil, &block ) proxyclass
new( address, port, p_addr, p_port ).start( &block )
end end
@is_proxy_class = false @is_proxy_class = false
@ -538,7 +552,6 @@ module Net
attr_reader :proxy_address attr_reader :proxy_address
attr_reader :proxy_port attr_reader :proxy_port
end end
def proxy? def proxy?
@ -556,40 +569,39 @@ module Net
alias proxyaddr proxy_address alias proxyaddr proxy_address
alias proxyport proxy_port alias proxyport proxy_port
private
# without proxy
def conn_address
address
end
def conn_port
port
end
def edit_path( path ) def edit_path( path )
path path
end end
module ProxyDelta
module ProxyMod
def self.create_proxy_class( p_addr, p_port )
mod = self
klass = Class.new( HTTP )
klass.module_eval {
include mod
@is_proxy_class = true
@proxy_address = p_addr
@proxy_port = p_port
}
klass
end
private private
# with proxy
def conn_address def conn_address
proxy_address() proxy_address
end end
def conn_port def conn_port
proxy_port() proxy_port
end end
def edit_path( path ) def edit_path( path )
'http://' + addr_port() + path 'http://' + addr_port() + path
end end
end
end # module ProxyMod
# #

View file

@ -601,7 +601,7 @@ module Net
BLOCK_SIZE = 1024 * 2 BLOCK_SIZE = 1024 * 2
def rbuf_fill def rbuf_fill
unless IO.select [@socket], nil, nil, @read_timeout then until IO.select [@socket], nil, nil, @read_timeout do
on_read_timeout on_read_timeout
end end
@rbuf << @socket.sysread(BLOCK_SIZE) @rbuf << @socket.sysread(BLOCK_SIZE)