From ead728ca7d7a42a3c1658d00102732947b514dea Mon Sep 17 00:00:00 2001 From: drbrain Date: Wed, 25 Jul 2012 00:05:59 +0000 Subject: * lib/net/http.rb: Added SSL session reuse across connections for a single instance to speed up connection. [Feature #5341] * NEWS: ditto * test/net/http/test_https.rb: Tests for #5341 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/net/http.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/net') diff --git a/lib/net/http.rb b/lib/net/http.rb index 357c41fbd7..0381099a07 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -649,6 +649,7 @@ module Net #:nodoc: @use_ssl = false @ssl_context = nil + @ssl_session = nil @enable_post_connection_check = true @sspi_enabled = false SSL_IVNAMES.each do |ivname| @@ -903,12 +904,14 @@ module Net #:nodoc: @socket.write(buf) HTTPResponse.read_new(@socket).value end + s.session = @ssl_session if @ssl_session # Server Name Indication (SNI) RFC 3546 s.hostname = @address if s.respond_to? :hostname= Timeout.timeout(@open_timeout, Net::OpenTimeout) { s.connect } if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE s.post_connection_check(@address) end + @ssl_session = s.session rescue => exception D "Conn close because of connect error #{exception}" @socket.close if @socket and not @socket.closed? -- cgit v1.2.3