Issue #4522 has been updated by Yui NARUSE.

Status changed from Open to Rejected

Recommended use of Net::HTTP is like:

 Net::HTTP.start("www.terra.com.br") do |h|
   h.get("/")
 end

So if a code is against this, it has some intention like the connection is one time connection.
On this recognition, current behavior seems reasonable.
----------------------------------------
Bug #4522: Net::HTTP persistent connections
http://redmine.ruby-lang.org/issues/4522

Author: Ricardo Amorim
Status: Rejected
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-linux]


Net::HTTP does not seem to follow HTTP 1.1 recommendations regarding persistent connections as per: http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html.

http://pastie.org/1710531 is a test script to reproduce the issue and inspect the TCPSocket:

Example 01 works according to RFC but it's required to manually initiate the connection before using any method (GET).
Example 02 shows that Net::HTTP sends a "Connection: close" header if the connection was not already open. This is not good :(
Example 03 shows that Net::HTTP properly sends a "Connection: keep-alive" header but closes the socket anyways. :(

I can post a patch if this issue is accepted.


-- 
http://redmine.ruby-lang.org