Class: WebMock::HttpLibAdapters::AsyncHttpClientAdapter

Inherits:
WebMock::HttpLibAdapter show all
Defined in:
lib/webmock/http_lib_adapters/async_http_client_adapter.rb

Constant Summary collapse

OriginalAsyncHttpClient =
Async::HTTP::Client

Class Method Summary collapse

Methods inherited from WebMock::HttpLibAdapter

adapter_for

Class Method Details

.disable!Object



35
36
37
38
# File 'lib/webmock/http_lib_adapters/async_http_client_adapter.rb', line 35

def disable!
  Async::HTTP.send(:remove_const, :Client)
  Async::HTTP.send(:const_set, :Client, OriginalAsyncHttpClient)
end

.enable!Object



30
31
32
33
# File 'lib/webmock/http_lib_adapters/async_http_client_adapter.rb', line 30

def enable!
  Async::HTTP.send(:remove_const, :Client)
  Async::HTTP.send(:const_set, :Client, Async::HTTP::WebMockClientWrapper)
end

.status_descriptionsObject

protocol-http1 0.40.0 removed Protocol::HTTP1::Reason in favour of Protocol::HTTP::Status. Resolved on first use, rather than at load, so it does not depend on which of the two is required by then.



22
23
24
25
26
27
28
# File 'lib/webmock/http_lib_adapters/async_http_client_adapter.rb', line 22

def status_descriptions
  @status_descriptions ||= if defined?(::Protocol::HTTP1::Reason)
                             ::Protocol::HTTP1::Reason::DESCRIPTIONS
                           else
                             ::Protocol::HTTP::Status::DESCRIPTIONS
                           end
end