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 respresents 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, #effective_url, #headers, #httpauth_avail, #namelookup_time, #pretransfer_time, #primary_ip, #redirect_count, #redirections, #response_body, #response_code, #response_headers, #return_code, #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



45
46
47
48
# File 'lib/typhoeus/response.rb', line 45

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

Instance Attribute Details

#handled_responseString

The handled response.

Returns:

  • (String)

Since:

  • 0.5.0



32
33
34
# File 'lib/typhoeus/response.rb', line 32

def handled_response
  @handled_response
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 wether this request is mocked or not.

Since:

  • 0.5.0



54
55
56
# File 'lib/typhoeus/response.rb', line 54

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

#optionsHash

The options provided, contains 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