module WebMockHTTPClients
def async_conn_for_stubbed_request(req, request_signature, webmock_response)
an extra response from the stub sequence. The thread only delivers what the caller
cached under, which makes the thread evaluate the stub registry again and consume
1 second resolution, so a signature built later can differ from the one the response was
Rebuilding calls headers_from_session again, and the session sets a Date header with
The async thread must not go through do_get, which would rebuild the request signature.
def async_conn_for_stubbed_request(req, request_signature, webmock_response) conn = HTTPClient::Connection.new conn.async_thread = Thread.new do begin WebMock::RequestRegistry.instance.requested_signatures.put(request_signature) response = build_httpclient_response(webmock_response, true, req.header) @request_filter.each do |filter| filter.filter_response(req, response) end conn.push(response) WebMock::CallbackRegistry.invoke_callbacks({lib: :httpclient}, request_signature, webmock_response) rescue Exception => e conn.push e end end conn end