module Async::HTTP::WebMockApplication
def add_webmock_response(request, webmock_response)
def add_webmock_response(request, webmock_response) webmock_request_id = request.object_id.to_s request.headers.add(WEBMOCK_REQUEST_ID_HEADER, webmock_request_id) webmock_responses[webmock_request_id] = webmock_response end
def build_response(webmock_response)
def build_response(webmock_response) headers = (webmock_response.headers || {}).each_with_object([]) do |(k, value), o| Array(value).each do |v| o.push [k, v] end end ::Protocol::HTTP::Response[ webmock_response.status[0], headers, webmock_response.body ] end
def call(request)
def call(request) request.read webmock_response = get_webmock_response(request) build_response(webmock_response) end
def get_webmock_response(request)
def get_webmock_response(request) webmock_request_id = request.headers[WEBMOCK_REQUEST_ID_HEADER][0] webmock_responses.fetch(webmock_request_id) end
def webmock_responses
def webmock_responses @webmock_responses ||= {} end