module Typhoeus::Responses::Status

def first_header_line

:nodoc:
def first_header_line
  @first_header_line ||= response_header.to_s.split("\n").first
end

def http_version

Returns:
  • (String) - The http version.

Other tags:
    Example: Return http version. -
def http_version
  @http_version ||= first_header_line ? first_header_line[/HTTP\/(\S+)/, 1] : nil
end

def modified?

Returns:
  • (Boolean) - Return true if modified, false else.

Other tags:
    Example: Return if the response was modified. -
def modified?
  response_code != 304
end

def status_message

Returns:
  • (String) - The message.

Other tags:
    Example: Return status message. -
def status_message
  return @status_message if defined?(@status_message) && @status_message
  # HTTP servers can choose not to include the explanation to HTTP codes. The RFC
  # states this (http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4):
  # Except when responding to a HEAD request, the server SHOULD include an entity containing
  # an explanation of the error situation [...]
  # This means 'HTTP/1.1 404' is as valid as 'HTTP/1.1 404 Not Found' and we have to handle it.
  # Regexp doc: http://rubular.com/r/eAr1oVYsVa
  if first_header_line != nil and first_header_line[/\d{3} (.*)$/, 1] != nil
    @status_message = first_header_line[/\d{3} (.*)$/, 1].chomp
  else
    @status_message = nil
  end
end

def success?

Returns:
  • (Boolean) - Return true if successful, false else.

Other tags:
    Example: Return if the response was successful. -
def success?
  (200..299).include?(response_code)
end

def timed_out?

Returns:
  • (Boolean) - Return true if timed out, false else.

Other tags:
    Example: Return if the response timed out.. -
def timed_out?
  return_code == 28
end