diff options
author | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-03-26 16:29:02 +0000 |
---|---|---|
committer | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-03-26 16:29:02 +0000 |
commit | bb5c66a7893b76b1cefbdaeeb30ea1454f7e463d (patch) | |
tree | 31c25d19e4337e28b74041118bf9a515c257d35d /lib | |
parent | 7718dcfb1eeb86b722bf08b244189b01197a2a28 (diff) | |
download | ruby-bb5c66a7893b76b1cefbdaeeb30ea1454f7e463d.tar.gz ruby-bb5c66a7893b76b1cefbdaeeb30ea1454f7e463d.tar.xz ruby-bb5c66a7893b76b1cefbdaeeb30ea1454f7e463d.zip |
o http.rb: return value of 'head' was wrong
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/net/http.rb | 38 | ||||
-rw-r--r-- | lib/net/protocol.rb | 2 |
2 files changed, 22 insertions, 18 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb index bdbcb82fd..14f9da400 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -89,7 +89,7 @@ class HTTPBadResponse < HTTPError; end def get( path, u_header = nil, dest = nil, &block ) - u_header ||= {} + u_header = procheader( u_header ) if block then dest = ReadAdapter.new( block ) ret = nil @@ -106,7 +106,8 @@ class HTTPBadResponse < HTTPError; end return resp['http-header'], ret end - def get2( path, u_header = {} ) + def get2( path, u_header = nil ) + u_header = procheader( u_header ) only_header( :get, path, u_header ) end @@ -120,14 +121,15 @@ class HTTPBadResponse < HTTPError; end dest end - def head( path, u_header = {} ) - ret = only_header( :head, path, u_header )['http-header'] + def head( path, u_header = nil ) + u_header = procheader( u_header ) + header = only_header( :head, path, u_header ) ensure_termination u_header - ret + header end def post( path, data, u_header = nil, dest = nil, &block ) - u_header ||= {} + u_header = procheader( u_header ) if block then dest = ReadAdapter.new( block ) ret = nil @@ -145,12 +147,13 @@ class HTTPBadResponse < HTTPError; end end def post2( path, data, u_header = {} ) + u_header = procheader( u_header ) only_header :post, path, u_header, data end # not tested because I could not setup apache (__;;; - def put( path, src = nil, u_header = {}, &block ) - u_header ||= u_header + def put( path, src = nil, u_header = nil, &block ) + u_header = procheader( u_header ) connecting( u_header, true ) { @command.put path, u_header, src, dest } @@ -163,13 +166,13 @@ class HTTPBadResponse < HTTPError; end def only_header( mid, path, u_header, data = nil ) - @u_header = u_header ? procheader(u_header) : {} + @u_header = u_header @response = nil - ensure_connection @u_header + ensure_connection u_header if data then - @command.send mid, edit_path(path), @u_header, data + @command.send mid, edit_path(path), u_header, data else - @command.send mid, edit_path(path), @u_header + @command.send mid, edit_path(path), u_header end @response = @command.get_response @response['http-header'] @@ -187,7 +190,6 @@ class HTTPBadResponse < HTTPError; end end def connecting( u_header, putp = false ) - u_header = procheader( u_header ) ensure_connection u_header yield ensure_termination u_header @@ -203,7 +205,7 @@ class HTTPBadResponse < HTTPError; end end def ensure_termination( u_header ) - unless keep_alive? u_header then + unless keep_alive? u_header and not @socket.closed? then @socket.close end @u_header = @response = nil @@ -224,6 +226,7 @@ class HTTPBadResponse < HTTPError; end end def procheader( h ) + return( {} ) unless h new = {} h.each do |k,v| arr = k.split('-') @@ -339,10 +342,11 @@ class HTTPBadResponse < HTTPError; end if clen = content_length( header ) then @socket.read clen, dest else - ### - ### "multipart/bytelenges" check should be done here ... - ### + ##### "multipart/byteranges" check should be done here ... + + # now, length is designated by closing socket @socket.read_all dest + @socket.close end end end diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb index 3a200d5d2..4f2bf17fd 100644 --- a/lib/net/protocol.rb +++ b/lib/net/protocol.rb @@ -15,7 +15,7 @@ require 'socket' module Net - Version = '1.1.9' + Version = '1.1.10' =begin |