summaryrefslogtreecommitdiff
path: root/lib/net/http.rb
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-02-07 17:17:51 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-02-07 17:17:51 +0000
commitb576f57aa02c4983eeb081f625c45b9445c50538 (patch)
tree6b0d719247f16754fed1edb105e1bed2f371a5ca /lib/net/http.rb
parent7e5f9d5a137848b54fe6ab33caebb2631e613bf5 (diff)
aamine
* lib/net/http.rb: join HTTPReadResponse into HTTPResponse again. * lib/net/http.rb: move http_version() from HTTPRequest to HTTPResponse. * lib/net/protocol.rb: refactoring. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net/http.rb')
-rw-r--r--lib/net/http.rb42
1 files changed, 15 insertions, 27 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 2f5d76c..4c39bb7 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -221,11 +221,6 @@ module Net
def do_finish
end
- def re_connect
- @socket.reopen @open_timeout
- on_connect
- end
-
###
### proxy
@@ -438,7 +433,7 @@ module Net
yield req
req.response.__send__ :terminate
- @curr_http_version = req.http_version
+ @curr_http_version = req.response.http_version
if keep_alive? req, req.response then
if @socket.closed? then
@@ -579,12 +574,10 @@ module Net
@socket = nil
@response = nil
- @http_version = nil
end
attr_reader :path
attr_reader :response
- attr_reader :http_version
def inspect
"\#<#{type}>"
@@ -633,6 +626,7 @@ module Net
ready( sock, ihead ) {|header|
request ver, path, header
}
+ @response
end
def ready( sock, ihead )
@@ -663,12 +657,6 @@ module Net
resp
end
- end
-
- module HTTPReadResponse
-
- private
-
def read_response
resp = get_resline
@@ -697,20 +685,16 @@ module Net
unless m then
raise HTTPBadResponse, "wrong status line: #{str}"
end
- @http_version = m[1]
+ httpver = m[1]
status = m[2]
discrip = m[3]
::Net::NetPrivate::HTTPResponse.new(
- status, discrip, @socket, type::HAS_BODY )
+ status, discrip, @socket, type::HAS_BODY, httpver )
end
end
- class HTTPRequest
- include ::Net::NetPrivate::HTTPReadResponse
- end
-
class HTTPRequestWithData < HTTPRequest
@@ -733,6 +717,7 @@ module Net
request ver, path, header
@socket.write data
}
+ @response
end
def check_arg( data, blkp )
@@ -792,7 +777,7 @@ module Net
METHOD = 'PUT'
end
- end # HTTP::
+ end
@@ -804,7 +789,7 @@ module Net
class HTTPResponse < Response
- HTTPCODE_CLASS_TO_OBJ = {
+ CODE_CLASS_TO_OBJ = {
'1' => HTTPInformationCode,
'2' => HTTPSuccessCode,
'3' => HTTPRedirectionCode,
@@ -812,7 +797,7 @@ module Net
'5' => HTTPServerErrorCode
}
- HTTPCODE_TO_OBJ = {
+ CODE_TO_OBJ = {
'100' => ContinueCode,
'101' => HTTPSwitchProtocol,
@@ -857,19 +842,22 @@ module Net
}
- def initialize( status, msg, sock, be )
- code = HTTPCODE_TO_OBJ[status] ||
- HTTPCODE_CLASS_TO_OBJ[status[0,1]] ||
+ def initialize( stat, msg, sock, be, hv )
+ code = CODE_TO_OBJ[stat] ||
+ CODE_CLASS_TO_OBJ[stat[0,1]] ||
UnknownCode
- super code, status, msg
+ super code, stat, msg
@socket = sock
@body_exist = be
+ @http_version = hv
@header = {}
@body = nil
@read = false
end
+ attr_reader :http_version
+
def inspect
"#<#{type} #{code}>"
end