You can clone with
I was bit by a variant of the issue Mislav mentioned in #188. It was significant work to tease apart because I'm using Mechanize and VCR and I'm not really familiar with the internals of any of the parts. However I was able to reduce this to a minimal test case:
uri = URI 'http://mubi.com/films/la-antena' # Arbitrary URI with Connection: close response header
http = Net::HTTP::Persistent.new 'test'
The error is:
gems/net-http-persistent-2.7/lib/net/http/persistent.rb:839:in `rescue in request': too
many connection resets (due to HTTP session not yet started - IOError)
after 0 requests on 70295747128800, last used
1345910926.7613492 seconds ago (Net::HTTP::Persistent::Error)
from gems/net-http-persistent-2.7/lib/net/http/persistent.rb:848:in `request'
The actual trigger of this error is the if connection_close?(req) condition in net/http/persistent.rb (line 812 in v2.7). This causes the connection to be closed, which for some reason (I haven't analyzed this yet, but I'm guessing it should be obvious to you) causes WebMock to refire the request. And when it refires it blows up.
This is fixed by the workaround described in the README of setting :net_http_connect_on_start to true, however that makes me worried about leaking connections when I don't want them. Ultimately I think the whole structure of NetHttpAdapter should be reconsidered with the semantics of net/http/persistent where connections are closed optionally right in the request method.
Fixed with WebMock 1.13.0