diff --git a/ChangeLog b/ChangeLog index 058ddd8796..13b0873b73 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Feb 8 05:31:48 2002 Minero Aoki + + * 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 * uri/common.rb (URI::join): new method. diff --git a/lib/net/http.rb b/lib/net/http.rb index f2a259a18a..e1bda208fa 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -453,7 +453,32 @@ module Net 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 @@ -461,11 +486,7 @@ module Net protocol_param :port, '80' - def initialize( addr, port = nil ) - super - @curr_http_version = HTTPVersion - @seems_1_0_server = false - end + HTTPVersion = '1.1' private @@ -506,26 +527,19 @@ module Net public class << self - def Proxy( p_addr, p_port = nil ) - if p_addr then - ProxyMod.create_proxy_class( p_addr, p_port || self.port ) - else - self - end - end + p_addr or return self - alias orig_new new - - def new( address, port = nil, p_addr = nil, p_port = nil ) - c = p_addr ? self::Proxy(p_addr, p_port) : self - i = c.orig_new( address, port ) - setimplversion i - i - end - - def start( address, port = nil, p_addr = nil, p_port = nil, &block ) - new( address, port, p_addr, p_port ).start( &block ) + p_port ||= port() + mod = ProxyDelta + proxyclass = Class.new(self) + proxyclass.module_eval { + include mod + @is_proxy_class = true + @proxy_address = p_addr + @proxy_port = p_port + } + proxyclass end @is_proxy_class = false @@ -538,7 +552,6 @@ module Net attr_reader :proxy_address attr_reader :proxy_port - end def proxy? @@ -556,40 +569,39 @@ module Net alias proxyaddr proxy_address alias proxyport proxy_port + private + + # without proxy + + def conn_address + address + end + + def conn_port + port + end + def edit_path( path ) path end - - 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 - + module ProxyDelta private + + # with proxy def conn_address - proxy_address() + proxy_address end def conn_port - proxy_port() + proxy_port end def edit_path( path ) 'http://' + addr_port() + path end - - end # module ProxyMod + end # diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb index f21bdf72f1..1cf1cfdb09 100644 --- a/lib/net/protocol.rb +++ b/lib/net/protocol.rb @@ -601,7 +601,7 @@ module Net BLOCK_SIZE = 1024 * 2 def rbuf_fill - unless IO.select [@socket], nil, nil, @read_timeout then + until IO.select [@socket], nil, nil, @read_timeout do on_read_timeout end @rbuf << @socket.sysread(BLOCK_SIZE)