Class: Typhoeus::Response

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

Overview

This class represents the response.

Since:

  • 0.5.0

Defined Under Namespace

Modules: Cacheable, Informations, Status Classes: Header

Instance Attribute Summary collapse

Attributes included from Cacheable

#cached

Instance Method Summary collapse

Methods included from Cacheable

#cached?

Methods included from Status

#failure?, #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, #redirect_time, #redirections, #request_size, #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


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_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


64
65
66
# File 'lib/typhoeus/response.rb', line 64

def handled_response
  @handled_response || self
end

#mockObject Also known as: mock?

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


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

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


29
30
31
# File 'lib/typhoeus/response.rb', line 29

def options
  @options
end

#requestTyphoeus::Request

Remembers the corresponding request.

Examples:

Get request.

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

Returns:

Since:

  • 0.5.0


23
24
25
# File 'lib/typhoeus/response.rb', line 23

def request
  @request
end