Class: Typhoeus::Response

Inherits:
Object
  • Object
show all
Includes:
Informations, Status
Defined in:
lib/typhoeus/response.rb,
lib/typhoeus/response/header.rb,
lib/typhoeus/response/status.rb,
lib/typhoeus/response/informations.rb

Overview

This class represents the response.

Since:

  • 0.5.0

Defined Under Namespace

Modules: Informations, Status Classes: Header

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Status

#http_version, #modified?, #status_message, #success?, #timed_out?

Methods included from Informations

#appconnect_time, #connect_time, #debug_info, #effective_url, #headers, #httpauth_avail, #namelookup_time, #pretransfer_time, #primary_ip, #redirect_count, #redirections, #response_body, #response_code, #response_headers, #return_code, #return_message, #starttransfer_time, #total_time

Constructor Details

#initialize(options = {}) ⇒ Response

Create a new response.

Examples:

Create a response.

Response.new

Parameters:

  • options (Hash) (defaults to: {})

    The options hash.

Since:

  • 0.5.0



43
44
45
46
# File 'lib/typhoeus/response.rb', line 43

def initialize(options = {})
  @options = options
  @headers = Header.new(options[:headers]) if options[:headers]
end

Instance Attribute Details

#handled_responseObject

Returns the handled_response if it has been defined; otherwise, returns the response

Returns:

  • (Object)

    The result of callbacks done on the response or the original response.

Since:

  • 0.5.0



61
62
63
# File 'lib/typhoeus/response.rb', line 61

def handled_response
  @handled_response || self
end

#mockObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns whether this request is mocked or not.

Since:

  • 0.5.0



52
53
54
# File 'lib/typhoeus/response.rb', line 52

def mock
  defined?(@mock) ? @mock : options[:mock]
end

#optionsHash

The provided options, which contain all the informations about the request.

Returns:

  • (Hash)

Since:

  • 0.5.0



27
28
29
# File 'lib/typhoeus/response.rb', line 27

def options
  @options
end

#requestTyphoeus::Request

Remembers the corresponding request.

Examples:

Get request.

request = Typhoeus::Request.get("www.example.com")
response = request.run
request == response.request
#=> true

Returns:

Since:

  • 0.5.0



21
22
23
# File 'lib/typhoeus/response.rb', line 21

def request
  @request
end