Parent

Class/Module Index [+]

Quicksearch

Curl::WebMockCurlEasy

Public Instance Methods

body_str() click to toggle source
Also aliased as: body_str_without_webmock
body_str_with_webmock() click to toggle source
# File lib/webmock/http_lib_adapters/curb_adapter.rb, line 250
def body_str_with_webmock
  @body_str || body_str_without_webmock
end
Also aliased as: body_str
body_str_without_webmock() click to toggle source
Alias for: body_str
build_curb_response(webmock_response) click to toggle source
# File lib/webmock/http_lib_adapters/curb_adapter.rb, line 105
def build_curb_response(webmock_response)
  raise Curl::Err::TimeoutError if webmock_response.should_timeout
  webmock_response.raise_error_if_any

  @body_str = webmock_response.body
  @response_code = webmock_response.status[0]

  @header_str = "HTTP/1.1 #{webmock_response.status[0]} #{webmock_response.status[1]}\r\n"
  if webmock_response.headers
    @header_str << webmock_response.headers.map do |k,v|
      "#{k}: #{v.is_a?(Array) ? v.join(", ") : v}"
    end.join("\r\n")

    location = webmock_response.headers['Location']
    if self.follow_location? && location
      @last_effective_url = location
      webmock_follow_location(location)
    end

    @content_type = webmock_response.headers["Content-Type"]
  end

  @last_effective_url ||= self.url
end
build_request_signature() click to toggle source
# File lib/webmock/http_lib_adapters/curb_adapter.rb, line 79
def build_request_signature
  method = @webmock_method.to_s.downcase.to_sym

  uri = WebMock::Util::URI.heuristic_parse(self.url)
  uri.path = uri.normalized_path.gsub("[^:]//","/")
  uri.user = self.username
  uri.password = self.password

  request_body = case method
  when :post
    self.post_body || @post_body
  when :put
    @put_data
  else
    nil
  end

  request_signature = WebMock::RequestSignature.new(
    method,
    uri.to_s,
    :body => request_body,
    :headers => self.headers
  )
  request_signature
end
build_webmock_response() click to toggle source
# File lib/webmock/http_lib_adapters/curb_adapter.rb, line 155
def build_webmock_response
  status, headers =
   WebMock::HttpLibAdapters::CurbAdapter.parse_header_string(self.header_str)

  webmock_response = WebMock::Response.new
  webmock_response.status = [self.response_code, status]
  webmock_response.body = self.body_str
  webmock_response.headers = headers
  webmock_response
end
content_type() click to toggle source
Also aliased as: content_type_without_webmock
content_type_with_webmock() click to toggle source
# File lib/webmock/http_lib_adapters/curb_adapter.rb, line 274
def content_type_with_webmock
  @content_type || content_type_without_webmock
end
Also aliased as: content_type
content_type_without_webmock() click to toggle source
Alias for: content_type
curb_or_webmock() click to toggle source
# File lib/webmock/http_lib_adapters/curb_adapter.rb, line 55
def curb_or_webmock
  request_signature = build_request_signature
  WebMock::RequestRegistry.instance.requested_signatures.put(request_signature)

  if webmock_response = WebMock::StubRegistry.instance.response_for_request(request_signature)
    build_curb_response(webmock_response)
    WebMock::CallbackRegistry.invoke_callbacks(
      {:lib => :curb}, request_signature, webmock_response)
    invoke_curb_callbacks
    true
  elsif WebMock.net_connect_allowed?(request_signature.uri)
    res = yield
    if WebMock::CallbackRegistry.any_callbacks?
      webmock_response = build_webmock_response
      WebMock::CallbackRegistry.invoke_callbacks(
        {:lib => :curb, :real_request => true}, request_signature,
          webmock_response)
    end
    res
  else
    raise WebMock::NetConnectNotAllowedError.new(request_signature)
  end
end
delete=(value) click to toggle source
Also aliased as: delete_without_webmock=
delete_with_webmock=(value) click to toggle source
# File lib/webmock/http_lib_adapters/curb_adapter.rb, line 236
def delete_with_webmock= value
  @webmock_method = :delete if value
  self.delete_without_webmock = value
end
Also aliased as: delete=
delete_without_webmock=(value) click to toggle source
Alias for: delete=
head=(value) click to toggle source
Also aliased as: head_without_webmock=
Alias for: head_with_webmock=
head_with_webmock=(value) click to toggle source
# File lib/webmock/http_lib_adapters/curb_adapter.rb, line 243
def head_with_webmock= value
  @webmock_method = :head if value
  self.head_without_webmock = value
end
Also aliased as: head=
head_without_webmock=(value) click to toggle source
Alias for: head=
header_str() click to toggle source
Also aliased as: header_str_without_webmock
header_str_with_webmock() click to toggle source
# File lib/webmock/http_lib_adapters/curb_adapter.rb, line 262
def header_str_with_webmock
  @header_str || header_str_without_webmock
end
Also aliased as: header_str
header_str_without_webmock() click to toggle source
Alias for: header_str
http(method) click to toggle source
Also aliased as: http_without_webmock
Alias for: http_with_webmock
http_post(*data) click to toggle source
Also aliased as: http_post_without_webmock
http_post_with_webmock(*data) click to toggle source
# File lib/webmock/http_lib_adapters/curb_adapter.rb, line 201
def http_post_with_webmock *data
  @webmock_method = :post
  @post_body = data.join('&') if data && !data.empty?
  curb_or_webmock do
    http_post_without_webmock(*data)
  end
end
Also aliased as: http_post
http_post_without_webmock(*data) click to toggle source
Alias for: http_post
http_put(data = nil) click to toggle source
Also aliased as: http_put_without_webmock
http_put_with_webmock(data = nil) click to toggle source
# File lib/webmock/http_lib_adapters/curb_adapter.rb, line 191
def http_put_with_webmock data = nil
  @webmock_method = :put
  @put_data = data if data
  curb_or_webmock do
    http_put_without_webmock(data)
  end
end
Also aliased as: http_put
http_put_without_webmock(data = nil) click to toggle source
Alias for: http_put
http_with_webmock(method) click to toggle source

Mocks of Curl::Easy methods below here.

# File lib/webmock/http_lib_adapters/curb_adapter.rb, line 170
def http_with_webmock(method)
  @webmock_method = method
  curb_or_webmock do
    http_without_webmock(method)
  end
end
Also aliased as: http
http_without_webmock(method) click to toggle source
Alias for: http
invoke_curb_callbacks() click to toggle source
# File lib/webmock/http_lib_adapters/curb_adapter.rb, line 141
def invoke_curb_callbacks
  @on_progress.call(0.0,1.0,0.0,1.0) if @on_progress
  @on_header.call(self.header_str) if @on_header
  @on_body.call(self.body_str) if @on_body
  @on_complete.call(self) if @on_complete

  case response_code
  when 200..299
    @on_success.call(self) if @on_success
  when 400..599
    @on_failure.call(self, self.response_code) if @on_failure
  end
end
last_effective_url() click to toggle source
last_effective_url_with_webmock() click to toggle source
# File lib/webmock/http_lib_adapters/curb_adapter.rb, line 268
def last_effective_url_with_webmock
  @last_effective_url || last_effective_url_without_webmock
end
Also aliased as: last_effective_url
last_effective_url_without_webmock() click to toggle source
Alias for: last_effective_url
perform() click to toggle source
Also aliased as: perform_without_webmock
perform_with_webmock() click to toggle source
# File lib/webmock/http_lib_adapters/curb_adapter.rb, line 212
def perform_with_webmock
  @webmock_method ||= :get
  curb_or_webmock do
    perform_without_webmock
  end
end
Also aliased as: perform
perform_without_webmock() click to toggle source
Alias for: perform
post_body=(data) click to toggle source
Also aliased as: post_body_without_webmock=
post_body_with_webmock=(data) click to toggle source
# File lib/webmock/http_lib_adapters/curb_adapter.rb, line 229
def post_body_with_webmock= data
  @webmock_method = :post
  self.post_body_without_webmock = data
end
Also aliased as: post_body=
post_body_without_webmock=(data) click to toggle source
Alias for: post_body=
put_data=(data) click to toggle source
Also aliased as: put_data_without_webmock=
put_data_with_webmock=(data) click to toggle source
# File lib/webmock/http_lib_adapters/curb_adapter.rb, line 221
def put_data_with_webmock= data
  @webmock_method = :put
  @put_data = data
  self.put_data_without_webmock = data
end
Also aliased as: put_data=
put_data_without_webmock=(data) click to toggle source
Alias for: put_data=
response_code() click to toggle source
response_code_with_webmock() click to toggle source
# File lib/webmock/http_lib_adapters/curb_adapter.rb, line 256
def response_code_with_webmock
  @response_code || response_code_without_webmock
end
Also aliased as: response_code
response_code_without_webmock() click to toggle source
Alias for: response_code
webmock_follow_location(location) click to toggle source
# File lib/webmock/http_lib_adapters/curb_adapter.rb, line 130
def webmock_follow_location(location)
  first_url = self.url
  self.url = location

  curb_or_webmock do
    send( "http_#{@webmock_method}_without_webmock" )
  end

  self.url = first_url
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.