summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-02-07 20:29:58 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-02-07 20:29:58 +0000
commitebd6cbda2fb3727a54735071ed9845765ffe5a06 (patch)
tree8f68994ff5bec2497c0014cca32498cf90e0c3fa /lib
parent848f886553e9a3cfdeb90940bad8bf9666619927 (diff)
aamine
* 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/branches/ruby_1_6@2057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/net/http.rb96
1 files changed, 54 insertions, 42 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 4bf907cc23..2a60608e81 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -404,13 +404,25 @@ module Net
class HTTP < Protocol
- HTTPVersion = '1.1'
-
#
- # connection
+ # constructors
#
- protocol_param :port, '80'
+ 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
@@ -418,6 +430,15 @@ module Net
@seems_1_0_server = false
end
+
+ #
+ # connection
+ #
+
+ protocol_param :port, '80'
+
+ HTTPVersion = '1.1'
+
private
def do_start
@@ -457,26 +478,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
-
- alias orig_new new
+ p_addr or return self
- 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
@@ -489,7 +503,6 @@ module Net
attr_reader :proxy_address
attr_reader :proxy_port
-
end
def proxy?
@@ -507,40 +520,39 @@ module Net
alias proxyaddr proxy_address
alias proxyport proxy_port
- def edit_path( path )
- path
- end
+ private
+ # without proxy
- module ProxyMod
+ def conn_address
+ address
+ end
- 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
+ def conn_port
+ port
+ end
+ def edit_path( path )
+ path
+ 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
#