Module: Async::HTTP::WebMockApplication
- Defined in:
- lib/webmock/http_lib_adapters/async_http_client_adapter.rb
Constant Summary collapse
- WEBMOCK_REQUEST_ID_HEADER =
'x-webmock-request-id'.freeze
Class Method Summary collapse
- .add_webmock_response(request, webmock_response) ⇒ Object
- .call(request) ⇒ Object
- .get_webmock_response(request) ⇒ Object
Class Method Details
.add_webmock_response(request, webmock_response) ⇒ Object
194 195 196 197 198 |
# File 'lib/webmock/http_lib_adapters/async_http_client_adapter.rb', line 194 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 |
.call(request) ⇒ Object
188 189 190 191 192 |
# File 'lib/webmock/http_lib_adapters/async_http_client_adapter.rb', line 188 def call(request) request.read webmock_response = get_webmock_response(request) build_response(webmock_response) end |
.get_webmock_response(request) ⇒ Object
200 201 202 203 |
# File 'lib/webmock/http_lib_adapters/async_http_client_adapter.rb', line 200 def get_webmock_response(request) webmock_request_id = request.headers[WEBMOCK_REQUEST_ID_HEADER][0] webmock_responses.fetch(webmock_request_id) end |