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


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

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


147
148
149
# File 'lib/typhoeus/response/informations.rb', line 147

def connect_time
  options[:connect_time]
end

#debug_infoObject

Since:

  • 0.5.0


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

def debug_info
  options[:debug_info]
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


169
170
171
# File 'lib/typhoeus/response/informations.rb', line 169

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


210
211
212
213
214
# File 'lib/typhoeus/response/informations.rb', line 210

def headers
  return Header.new(options[:headers]) if mock? && options[:headers]
  return nil if response_headers.nil? && !defined?(@headers)
  @headers ||= 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


78
79
80
# File 'lib/typhoeus/response/informations.rb', line 78

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


158
159
160
# File 'lib/typhoeus/response/informations.rb', line 158

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


136
137
138
# File 'lib/typhoeus/response/informations.rb', line 136

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


181
182
183
# File 'lib/typhoeus/response/informations.rb', line 181

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


192
193
194
# File 'lib/typhoeus/response/informations.rb', line 192

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


224
225
226
227
# File 'lib/typhoeus/response/informations.rb', line 224

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

#request_sizeObject

Since:

  • 0.5.0


196
197
198
# File 'lib/typhoeus/response/informations.rb', line 196

def request_size
  options[:request_size]
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


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

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


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

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


47
48
49
50
51
52
53
54
# File 'lib/typhoeus/response/informations.rb', line 47

def response_headers
  return options[:response_headers] if options[:response_headers]
  if mock? && h = options[:headers]
      h.map{ |k,v| [k, v.respond_to?(:join) ? v.join : v] }.
        map{ |e| "#{e.first}: #{e.last}" }.
        join("\r\n")
  end
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

#return_messageString

Returns a string describing the return.

Examples:

Get return_message.

response.return_message

Returns:

  • (String)

    The return_message.

Since:

  • 0.6.2


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

def return_message
  Ethon::Curl.easy_strerror(return_code) if 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


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

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


90
91
92
# File 'lib/typhoeus/response/informations.rb', line 90

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