On 10/26/2011 11:39 AM, Eric Hodel wrote:
> Net::HTTP objects can be reused.  You may start and finish a
> connection as many times as you like (the net-http-persistent gem
> works this way).

OK, so it's just I was wrong.  I felt that I saw an issue for
restarting Net::HTTP with #start after #finish, but I cannot find a
ticket.  I'm just confusing it with another issue.  Either it's
already fixed.

> Currently the SSLSession can only be initialized once due to
> OpenSSL restrictions.  To change the values you must make a new
> Net::HTTP object, so I think changing this behavior (if it is
> needed) is a separate issue.

SSLSocket --<>> SSLContext <<>-- Session
    <>                              A
     |                              |
     +------------------------------+

You can't modify SSLContext after you create SSLSocket.  You must
create new SSLContext for new SSLSocket if you need to update ssl
params.  It might conflict with semantics of Net::HTTP object, thought
I don't have any idea what Net::HTTP object should know.

> I will update the patch to check for the timeout, I did not know it
> existed.

OpenSSL has a client session cache in SSLContext but it's not so
useful because you need to keep Sessions by yourself, and pick proper
Session for each server.  Here's a sample usage of client session cache:

https://github.com/nahi/httpclient/commit/7fc04933961ea3ea5a2aa595172ca7cd29a718f5

You would want to implement session cache instead.

FYI: In contrast to the client session cache, the server session cache
is very useful and everyone should use it whenever you need a server
session cache.

> With this code:
> 
> https://github.com/drbrain/net-http-persistent/blob/master/lib/net/http/persistent/ssl_reuse.rb
>
>  I was only able to reproduce the issue on Ruby 1.9.1, not Ruby
> 1.8.7, 1.9.2, 1.9.3 or ruby trunk.

Thank you.  I'll try to reproduce it.