Parent

Class/Module Index [+]

Quicksearch

WebMock::HttpLibAdapters::PatronAdapter::WebMockPatronSession

Public Instance Methods

handle_request(req) click to toggle source
handle_request_with_webmock(req) click to toggle source
# File lib/webmock/http_lib_adapters/patron_adapter.rb, line 16
def handle_request_with_webmock(req)
  request_signature =
    WebMock::HttpLibAdapters::PatronAdapter.build_request_signature(req)

  WebMock::RequestRegistry.instance.requested_signatures.put(request_signature)

  if webmock_response = WebMock::StubRegistry.instance.response_for_request(request_signature)
    WebMock::HttpLibAdapters::PatronAdapter.
      handle_file_name(req, webmock_response)
    res = WebMock::HttpLibAdapters::PatronAdapter.
      build_patron_response(webmock_response, default_response_charset)
    WebMock::CallbackRegistry.invoke_callbacks(
      {:lib => :patron}, request_signature, webmock_response)
    res
  elsif WebMock.net_connect_allowed?(request_signature.uri)
    res = handle_request_without_webmock(req)
    if WebMock::CallbackRegistry.any_callbacks?
      webmock_response = WebMock::HttpLibAdapters::PatronAdapter.
        build_webmock_response(res)
      WebMock::CallbackRegistry.invoke_callbacks(
        {:lib => :patron, :real_request => true}, request_signature,
          webmock_response)
    end
    res
  else
    raise WebMock::NetConnectNotAllowedError.new(request_signature)
  end
end
Also aliased as: handle_request
handle_request_without_webmock(req) click to toggle source
Alias for: handle_request

[Validate]

Generated with the Darkfish Rdoc Generator 2.