Bug #4246 » net.http.ssl.connection.timeout.patch
| lib/net/http.rb | ||
|---|---|---|
|
@socket.read_timeout = @read_timeout
|
||
|
@socket.debug_output = @debug_output
|
||
|
if use_ssl?
|
||
|
if proxy?
|
||
|
@socket.writeline sprintf('CONNECT %s:%s HTTP/%s',
|
||
|
@address, @port, HTTPVersion)
|
||
|
@socket.writeline "Host: #{@address}:#{@port}"
|
||
|
if proxy_user
|
||
|
credential = ["#{proxy_user}:#{proxy_pass}"].pack('m')
|
||
|
credential.delete!("\r\n")
|
||
|
@socket.writeline "Proxy-Authorization: Basic #{credential}"
|
||
|
begin
|
||
|
if proxy?
|
||
|
@socket.writeline sprintf('CONNECT %s:%s HTTP/%s',
|
||
|
@address, @port, HTTPVersion)
|
||
|
@socket.writeline "Host: #{@address}:#{@port}"
|
||
|
if proxy_user
|
||
|
credential = ["#{proxy_user}:#{proxy_pass}"].pack('m')
|
||
|
credential.delete!("\r\n")
|
||
|
@socket.writeline "Proxy-Authorization: Basic #{credential}"
|
||
|
end
|
||
|
@socket.writeline ''
|
||
|
HTTPResponse.read_new(@socket).value
|
||
|
end
|
||
|
@socket.writeline ''
|
||
|
HTTPResponse.read_new(@socket).value
|
||
|
end
|
||
|
s.connect
|
||
|
if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE
|
||
|
s.post_connection_check(@address)
|
||
|
timeout(@open_timeout) { s.connect }
|
||
|
if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE
|
||
|
s.post_connection_check(@address)
|
||
|
end
|
||
|
rescue => exception
|
||
|
D "Conn close because of connect error #{exception}"
|
||
|
@socket.close if @socket and not @socket.closed?
|
||
|
raise exception
|
||
|
end
|
||
|
end
|
||
|
on_connect
|
||