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.
Instance Method Summary collapse
-
#appconnect_time ⇒ Float
(also: #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.
-
#connect_time ⇒ Float
Return the time, in seconds, it took from the start until the connect to the remote host (or proxy) was completed.
- #debug_info ⇒ Object
-
#effective_url ⇒ String
Return the last used effective url.
-
#headers ⇒ Typhoeus::Header
(also: #headers_hash)
Returns the response header.
-
#httpauth_avail ⇒ Integer
Return the available http auth methods.
-
#namelookup_time ⇒ Float
(also: #name_lookup_time)
Return the time, in seconds, it took from the start until the name resolving was completed.
-
#pretransfer_time ⇒ Float
Return the time, in seconds, it took from the start until the file transfer is just about to begin.
-
#primary_ip ⇒ String
Return the string holding the IP address of the most recent connection done with this curl handle.
-
#redirect_count ⇒ Integer
Return the total number of redirections that were actually followed.
-
#redirect_time ⇒ Float
Return the time, in seconds, it took for all redirection steps include name lookup, connect, pretransfer and transfer before the final transaction was started.
-
#redirections ⇒ Array<Typhoeus::Response>
Return all redirections in between as multiple responses with header.
- #request_size ⇒ Object
-
#response_body ⇒ String
(also: #body)
Return the http response body.
-
#response_code ⇒ Integer
(also: #code)
Return the last received HTTP, FTP or SMTP response code.
-
#response_headers ⇒ String
Return the http response headers.
-
#return_code ⇒ Symbol
Return libcurls return value.
-
#return_message ⇒ String
Returns a string describing the return.
-
#starttransfer_time ⇒ Float
(also: #start_transfer_time)
Return the time, in seconds, it took from the start until the first byte is received by libcurl.
-
#total_time ⇒ Float
(also: #time)
Return the total time in seconds for the previous transfer, including name resolving, TCP connect etc.
Instance Method Details
#appconnect_time ⇒ Float 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.
124 125 126 |
# File 'lib/typhoeus/response/informations.rb', line 124 def appconnect_time [:appconnect_time] || [:app_connect_time] end |
#connect_time ⇒ Float
Return the time, in seconds, it took from the start until the connect to the remote host (or proxy) was completed.
151 152 153 |
# File 'lib/typhoeus/response/informations.rb', line 151 def connect_time [:connect_time] end |
#debug_info ⇒ Object
217 218 219 |
# File 'lib/typhoeus/response/informations.rb', line 217 def debug_info [:debug_info] end |
#effective_url ⇒ String
Return the last used effective url.
186 187 188 |
# File 'lib/typhoeus/response/informations.rb', line 186 def effective_url [:effective_url] end |
#headers ⇒ Typhoeus::Header Also known as: headers_hash
Returns the response header.
227 228 229 230 231 |
# File 'lib/typhoeus/response/informations.rb', line 227 def headers return Header.new([:headers]) if mock? && [:headers] return nil if response_headers.nil? && !defined?(@headers) @headers ||= Header.new(response_headers.split("\r\n\r\n").last) end |
#httpauth_avail ⇒ Integer
Return the available http auth methods. Bitmask indicating the authentication method(s) available.
82 83 84 |
# File 'lib/typhoeus/response/informations.rb', line 82 def httpauth_avail [:httpauth_avail] end |
#namelookup_time ⇒ Float Also known as: name_lookup_time
Return the time, in seconds, it took from the start until the name resolving was completed.
162 163 164 |
# File 'lib/typhoeus/response/informations.rb', line 162 def namelookup_time [:namelookup_time] || [:name_lookup_time] end |
#pretransfer_time ⇒ Float
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.
140 141 142 |
# File 'lib/typhoeus/response/informations.rb', line 140 def pretransfer_time [:pretransfer_time] end |
#primary_ip ⇒ String
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.
198 199 200 |
# File 'lib/typhoeus/response/informations.rb', line 198 def primary_ip [:primary_ip] end |
#redirect_count ⇒ Integer
Return the total number of redirections that were actually followed
209 210 211 |
# File 'lib/typhoeus/response/informations.rb', line 209 def redirect_count [:redirect_count] end |
#redirect_time ⇒ Float
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.
176 177 178 |
# File 'lib/typhoeus/response/informations.rb', line 176 def redirect_time [:redirect_time] end |
#redirections ⇒ Array<Typhoeus::Response>
Return all redirections in between as multiple responses with header.
241 242 243 244 |
# File 'lib/typhoeus/response/informations.rb', line 241 def redirections return [] unless response_headers response_headers.split("\r\n\r\n")[0..-2].map{ |h| Response.new(:response_headers => h) } end |
#request_size ⇒ Object
213 214 215 |
# File 'lib/typhoeus/response/informations.rb', line 213 def request_size [:request_size] end |
#response_body ⇒ String Also known as: body
Return the http response body.
36 37 38 |
# File 'lib/typhoeus/response/informations.rb', line 36 def response_body [:response_body] || [:body] end |
#response_code ⇒ Integer 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.
69 70 71 |
# File 'lib/typhoeus/response/informations.rb', line 69 def response_code ([:response_code] || [:code]).to_i end |
#response_headers ⇒ String
Return the http response headers.
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/typhoeus/response/informations.rb', line 47 def response_headers return [:response_headers] if [:response_headers] if mock? && h = [: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_code ⇒ Symbol
Return libcurls return value.
14 15 16 |
# File 'lib/typhoeus/response/informations.rb', line 14 def return_code [:return_code] end |
#return_message ⇒ String
Returns a string describing the return.
26 27 28 |
# File 'lib/typhoeus/response/informations.rb', line 26 def Ethon::Curl.easy_strerror(return_code) if return_code end |
#starttransfer_time ⇒ Float 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.
108 109 110 |
# File 'lib/typhoeus/response/informations.rb', line 108 def starttransfer_time [:starttransfer_time] || [:start_transfer_time] end |
#total_time ⇒ Float Also known as: time
Return the total time in seconds for the previous transfer, including name resolving, TCP connect etc.
94 95 96 |
# File 'lib/typhoeus/response/informations.rb', line 94 def total_time [:total_time] || [:time] end |