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


124
125
126
# File 'lib/typhoeus/response/informations.rb', line 124

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


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

def connect_time
  options[:connect_time]
end

#debug_infoObject

Since:

  • 0.5.0


264
265
266
# File 'lib/typhoeus/response/informations.rb', line 264

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


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

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


274
275
276
277
278
# File 'lib/typhoeus/response/informations.rb', line 274

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


82
83
84
# File 'lib/typhoeus/response/informations.rb', line 82

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


162
163
164
# File 'lib/typhoeus/response/informations.rb', line 162

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


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

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


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

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


209
210
211
# File 'lib/typhoeus/response/informations.rb', line 209

def redirect_count
  options[:redirect_count]
end

#redirect_timeFloat

Return the time, in seconds, it took for all redirection steps include name lookup, connect, pretransfer and transfer before the final transaction was started. time_redirect shows the complete execution time for multiple redirections.

Examples:

Get redirect_time.

response.redirect_time

Returns:

  • (Float)

    The redirect_time.

Since:

  • 0.5.0


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

def redirect_time
  options[:redirect_time]
end

#redirectionsArray<Typhoeus::Response>

Return all redirections in between as multiple responses with header.

Examples:

Return redirections.

response.redirections

Returns:

Since:

  • 0.5.0


288
289
290
291
# File 'lib/typhoeus/response/informations.rb', line 288

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


213
214
215
# File 'lib/typhoeus/response/informations.rb', line 213

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


69
70
71
# File 'lib/typhoeus/response/informations.rb', line 69

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
55
56
57
58
# File 'lib/typhoeus/response/informations.rb', line 47

def response_headers
  return options[:response_headers] if options[:response_headers]
  if mock? && h = options[:headers]
      status_code = return_code || "200"
      reason_phrase = status_code == "200" ? "OK" : "Mock Reason Phrase"
      status_line = "HTTP/1.1 #{status_code} #{reason_phrase}"
      actual_headers = h.map{ |k,v| [k, v.respond_to?(:join) ? v.join(',') : v] }.
        map{ |e| "#{e.first}: #{e.last}" }

      [status_line, *actual_headers].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

#size_downloadFloat

Return the bytes, the total amount of bytes that were downloaded. The amount is only for the latest transfer and will be reset again for each new transfer. This counts actual payload data, what's also commonly called body. All meta and header data are excluded and will not be counted in this number.

Examples:

Get size_download

response.size_download

Returns:

  • (Float)

    The size_download.

Since:

  • 0.5.0


238
239
240
# File 'lib/typhoeus/response/informations.rb', line 238

def size_download
  options[:size_download]
end

#size_uploadFloat

Return the bytes, the total amount of bytes that were uploaded

Examples:

Get size_upload.

response.size_upload

Returns:

  • (Float)

    The size_upload.

Since:

  • 0.5.0


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

def size_upload
  options[:size_upload]
end

#speed_downloadFloat

Return the bytes/second, the average download speed that curl measured for the complete download

Examples:

Get speed_download.

response.speed_download

Returns:

  • (Float)

    The speed_download.

Since:

  • 0.5.0


260
261
262
# File 'lib/typhoeus/response/informations.rb', line 260

def speed_download
  options[:speed_download]
end

#speed_uploadFloat

Return the bytes/second, the average upload speed that curl measured for the complete upload

Examples:

Get speed_upload.

response.speed_upload

Returns:

  • (Float)

    The speed_upload.

Since:

  • 0.5.0


249
250
251
# File 'lib/typhoeus/response/informations.rb', line 249

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


108
109
110
# File 'lib/typhoeus/response/informations.rb', line 108

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


94
95
96
# File 'lib/typhoeus/response/informations.rb', line 94

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