class Patron::Response

Represents the response from the HTTP server.

Attributes

body[R]
charset[R]
headers[R]
redirect_count[R]
status[R]
status_line[R]
url[R]

Public Class Methods

new(url, status, redirect_count, header_data, body, default_charset = nil) click to toggle source
# File lib/patron/response.rb, line 31
def initialize(url, status, redirect_count, header_data, body, default_charset = nil)
  # Don't let a response clear out the default charset, which would cause encoding to fail
  default_charset = "ASCII-8BIT" unless default_charset
  @url            = url
  @status         = status
  @redirect_count = redirect_count
  @body           = body
  
  @charset        = determine_charset(header_data, body) || default_charset
  
  [url, header_data].each do |attr|
    convert_to_default_encoding!(attr)
  end
  
  parse_headers(header_data)
  if @headers["Content-Type"] && @headers["Content-Type"][0, 5] == "text/"
    convert_to_default_encoding!(@body)
  end
end

Public Instance Methods

inspect() click to toggle source
# File lib/patron/response.rb, line 53
def inspect
  # Avoid spamming the console with the header and body data
  "#<Patron::Response @status_line='#{@status_line}'>"
end