From 9e79454b3d6476ff0da11ae7917b25edd8057f1d Mon Sep 17 00:00:00 2001 From: aamine Date: Tue, 3 Jul 2001 19:03:16 +0000 Subject: aamine * lib/net/http.rb (HTTP#request_by_name): bug fix. * lib/net/http.rb: does not write Connection: by default. * lib/net/protocol.rb: "start" for started protocol is an error. * lib/net/protocol.rb: "finish" for finished protocol is an error. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/net/http.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'lib/net/http.rb') diff --git a/lib/net/http.rb b/lib/net/http.rb index f0c7dbff6c..20c8d0107d 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -203,7 +203,7 @@ Yes, this is not thread-safe. : finish finishes HTTP session. - If HTTP session had not started, do nothing and return false. + If HTTP session had not started, raises an IOError. : proxy? true if self is a HTTP proxy class @@ -610,7 +610,7 @@ module Net req.response end - def request_by_name( name, path, header, body = nil ) + def request_by_name( name, path, header = nil, body = nil ) r = ::Net::NetPrivate::HTTPGenericRequest.new( name, body ? true : false, true, path, header ) @@ -622,17 +622,20 @@ module Net def connecting( req ) - req['connection'] ||= 'keep-alive' + unless active? then + implicit = true + req['connection'] ||= 'close' + end + if not @socket then start - req['connection'] = 'close' elsif @socket.closed? then re_connect end if not req.body_exist? or @seems_1_0_server then req['connection'] = 'close' end - req['host'] = addr_port + req['host'] = addr_port() yield req req.response.__send__ :terminate @@ -651,6 +654,10 @@ module Net D 'Conn close' @socket.close end + + if implicit then + finish + end end def keep_alive?( req, res ) -- cgit v1.2.3