Bug #14349 » net-http-reuse-connections.patch
| lib/net/http.rb (working copy) | ||
|---|---|---|
|
# This method never raises Net::* exceptions.
|
||
|
#
|
||
|
def request(req, body = nil, &block) # :yield: +response+
|
||
|
unless started?
|
||
|
start {
|
||
|
req['connection'] ||= 'close'
|
||
|
return request(req, body, &block)
|
||
|
}
|
||
|
end
|
||
|
start unless started?
|
||
|
if proxy_user()
|
||
|
req.proxy_basic_auth proxy_user(), proxy_pass() unless use_ssl?
|
||
|
end
|
||
| test/net/http/test_http.rb (working copy) | ||
|---|---|---|
|
include TestNetHTTPUtils
|
||
|
def test_keep_alive_using_new
|
||
|
http = new
|
||
|
http.keep_alive_timeout = 1
|
||
|
res = http.get('/')
|
||
|
assert_kind_of Net::HTTPResponse, res
|
||
|
assert_kind_of String, res.body
|
||
|
socket = http.instance_variable_get(:@socket)
|
||
|
refute(socket.closed?, 'Expected socket to be kept open')
|
||
|
res = http.get('/')
|
||
|
assert_kind_of Net::HTTPResponse, res
|
||
|
assert_kind_of String, res.body
|
||
|
end
|
||
|
def test_keep_alive_get_auto_reconnect
|
||
|
start {|http|
|
||
|
res = http.get('/')
|
||