summaryrefslogtreecommitdiff
path: root/lib/net/http.rb
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-01-21 12:52:24 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-01-21 12:52:24 +0000
commit005f12582975d8382851b740690f97dba35aaa2a (patch)
tree02f9fffe3b8d7b4c24fdcf28755c49f03db97220 /lib/net/http.rb
parente5ed1780afa9a5f29da7c63ca2b7d9c66f6936aa (diff)
Version 1.1.4
o (HTTP) allow no content-length data git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net/http.rb')
-rw-r--r--lib/net/http.rb16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 3f0f47e31e..4847f88bf7 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -57,8 +57,6 @@ class HTTPBadResponse < HTTPError; end
class HTTP < Protocol
- Version = '1.1.3'
-
protocol_param :port, '80'
protocol_param :command_type, '::Net::HTTPCommand'
@@ -143,7 +141,7 @@ class HTTPBadResponse < HTTPError; end
@in_header = {}
@in_header[ 'Host' ] = sock.addr
- @in_header[ 'Connection' ] = 'keep-alive'
+ @in_header[ 'Connection' ] = 'Keep-Alive'
@in_header[ 'Accept' ] = '*/*'
super sock
@@ -161,7 +159,11 @@ class HTTPBadResponse < HTTPError; end
header.delete 'transfer-encoding'
header[ 'content-length' ] = "Content-Length: #{clen}"
else
- @socket.read content_length( header ), ret
+ if clen = content_length( header ) then
+ @socket.read clen, ret
+ else
+ @socket.read_all ret
+ end
end
header
@@ -229,10 +231,10 @@ class HTTPBadResponse < HTTPError; end
def content_length( header )
unless str = header[ 'content-length' ] then
- raise HTTPBadResponce, "content-length not given"
+ return nil
end
unless /\Acontent-length:\s*(\d+)/i === str then
- raise HTTPBadResponce, "content-length format error"
+ raise HTTPBadResponse, "content-length format error"
end
$1.to_i
end
@@ -289,7 +291,7 @@ class HTTPBadResponse < HTTPError; end
while true do
line = @socket.readline
unless /[0-9a-hA-H]+/ === line then
- raise HTTPBadResponce, "chunk size not given"
+ raise HTTPBadResponse, "chunk size not given"
end
len = $&.hex
break if len == 0