Module: Typhoeus::Response::Informations

Included in:
Typhoeus::Response
Defined in:
lib/typhoeus/response/informations.rb

Overview

This module contains logic about informations on a response.

Since:

  • 0.5.0

Instance Method Summary collapse

Instance Method Details

#appconnect_timeFloat Also known as: app_connect_time

Return the time, in seconds, it took from the start until the SSL/SSH connect/handshake to the remote host was completed. This time is most often very near to the pre transfer time, except for cases such as HTTP pippelining where the pretransfer time can be delayed due to waits in line for the pipeline and more.

Examples:

Get appconnect_time.

response.appconnect_time

Returns:

  • (Float)

    The appconnect_time.

Since:

  • 0.5.0



103
104
105
# File 'lib/typhoeus/response/informations.rb', line 103

def appconnect_time
  options[:appconnect_time] || options[:app_connect_time]
end

#connect_timeFloat

Return the time, in seconds, it took from the start until the connect to the remote host (or proxy) was completed.

Examples:

Get connect_time.

response.connect_time

Returns:

  • (Float)

    The connect_time.

Since:

  • 0.5.0



130
131
132
# File 'lib/typhoeus/response/informations.rb', line 130

def connect_time
  options[:connect_time]
end

#effective_urlString

Return the last used effective url.

Examples:

Get effective_url.

response.effective_url

Returns:

  • (String)

    The effective_url.

Since:

  • 0.5.0



152
153
154
# File 'lib/typhoeus/response/informations.rb', line 152

def effective_url
  options[:effective_url]
end

#headersTyphoeus::Header Also known as: headers_hash

Returns the response header.

Examples:

Return headers.

response.headers

Returns:

  • (Typhoeus::Header)

    The response header.

Since:

  • 0.5.0



185
186
187
188
# File 'lib/typhoeus/response/informations.rb', line 185

def headers
  return nil if response_headers.nil? && @headers.nil?
  @headers ||= Response::Header.new(response_headers.split("\r\n\r\n").last)
end

#httpauth_availInteger

Return the available http auth methods. Bitmask indicating the authentication method(s) available.

Examples:

Get httpauth_avail.

response.httpauth_avail

Returns:

  • (Integer)

    The bitmask.

Since:

  • 0.5.0



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

def httpauth_avail
  options[:httpauth_avail]
end

#namelookup_timeFloat Also known as: name_lookup_time

Return the time, in seconds, it took from the start until the name resolving was completed.

Examples:

Get namelookup_time.

response.namelookup_time

Returns:

  • (Float)

    The namelookup_time.

Since:

  • 0.5.0



141
142
143
# File 'lib/typhoeus/response/informations.rb', line 141

def namelookup_time
  options[:namelookup_time] || options[:name_lookup_time]
end

#pretransfer_timeFloat

Return the time, in seconds, it took from the start until the file transfer is just about to begin. This includes all pre-transfer commands and negotiations that are specific to the particular protocol(s) involved. It does not involve the sending of the protocol- specific request that triggers a transfer.

Examples:

Get pretransfer_time.

response.pretransfer_time

Returns:

  • (Float)

    The pretransfer_time.

Since:

  • 0.5.0



119
120
121
# File 'lib/typhoeus/response/informations.rb', line 119

def pretransfer_time
  options[:pretransfer_time]
end

#primary_ipString

Return the string holding the IP address of the most recent connection done with this curl handle. This string may be IPv6 if that’s enabled.

Examples:

Get primary_ip.

response.primary_ip

Returns:

  • (String)

    The primary_ip.

Since:

  • 0.5.0



164
165
166
# File 'lib/typhoeus/response/informations.rb', line 164

def primary_ip
  options[:primary_ip]
end

#redirect_countInteger

Return the total number of redirections that were actually followed

Examples:

Get redirect_count.

response.redirect_count

Returns:

  • (Integer)

    The redirect_count.

Since:

  • 0.5.0



175
176
177
# File 'lib/typhoeus/response/informations.rb', line 175

def redirect_count
  options[:redirect_count]
end

#redirectionsArray<Typhoeus::Response>

Return all redirections in between as multiple responses with header.

Examples:

Return redirections.

response.redirections

Returns:

Since:

  • 0.5.0



198
199
200
201
# File 'lib/typhoeus/response/informations.rb', line 198

def redirections
  return [] unless response_headers
  response_headers.split("\r\n\r\n")[0..-2].map{ |h| Response.new(:response_headers => h) }
end

#response_bodyString Also known as: body

Return the http response body.

Examples:

Get response_body.

response.response_body

Returns:

  • (String)

    The response_body.

Since:

  • 0.5.0



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

def response_body
  options[:response_body] || options[:body]
end

#response_codeInteger Also known as: code

Return the last received HTTP, FTP or SMTP response code. The value will be zero if no server response code has been received. Note that a proxy’s CONNECT response should be read with http_connect_code and not this.

Examples:

Get response_code.

response.response_code

Returns:

  • (Integer)

    The response_code.

Since:

  • 0.5.0



48
49
50
# File 'lib/typhoeus/response/informations.rb', line 48

def response_code
  (options[:response_code] || options[:code]).to_i
end

#response_headersString

Return the http response headers.

Examples:

Get response_headers.

response.response_headers

Returns:

  • (String)

    The response_headers.

Since:

  • 0.5.0



35
36
37
# File 'lib/typhoeus/response/informations.rb', line 35

def response_headers
  options[:response_headers]
end

#return_codeSymbol

Return libcurls return value.

Examples:

Get return_code.

response.return_code

Returns:

  • (Symbol)

    The return_code.

Since:

  • 0.5.0



14
15
16
# File 'lib/typhoeus/response/informations.rb', line 14

def return_code
  options[:return_code]
end

#starttransfer_timeFloat Also known as: start_transfer_time

Return the time, in seconds, it took from the start until the first byte is received by libcurl. This includes pretransfer time and also the time the server needs to calculate the result.

Examples:

Get starttransfer_time.

response.starttransfer_time

Returns:

  • (Float)

    The starttransfer_time.

Since:

  • 0.5.0



87
88
89
# File 'lib/typhoeus/response/informations.rb', line 87

def starttransfer_time
  options[:starttransfer_time] || options[:start_transfer_time]
end

#total_timeFloat Also known as: time

Return the total time in seconds for the previous transfer, including name resolving, TCP connect etc.

Examples:

Get total_time.

response.total_time

Returns:

  • (Float)

    The total_time.

Since:

  • 0.5.0



73
74
75
# File 'lib/typhoeus/response/informations.rb', line 73

def total_time
  options[:total_time] || options[:time]
end