class HTTP::Response

def charset

Returns:
  • (String, nil) -
def charset
  @charset ||= content_type.charset
end

def content_type

Returns:
  • (HTTP::ContentType) -
def content_type
  @content_type ||= ContentType.parse headers['Content-Type']
end

def flush

Flushes body and returns self-reference
def flush
  body.to_s
  self
end

def initialize(status, version, headers, body, uri = nil) # rubocop:disable ParameterLists

rubocop:disable ParameterLists
def initialize(status, version, headers, body, uri = nil) # rubocop:disable ParameterLists
  @status, @version, @body, @uri = status, version, body, uri
  @headers = HTTP::Headers.coerce(headers || {})
end

def inspect

Inspect a response
def inspect
  "#<#{self.class}/#{@version} #{status} #{reason} headers=#{headers.inspect}>"
end

def mime_type

Returns:
  • (String, nil) -
def mime_type
  @mime_type ||= content_type.mime_type
end

def parse(as = nil)

Returns:
  • (Object) -

Raises:
  • (Error) - if adapter not found

Parameters:
  • as (#to_s) -- Parse as given MIME type
def parse(as = nil)
  MimeType[as || mime_type].decode to_s
end

def reason

Obtain the 'Reason-Phrase' for the response
def reason
  STATUS_CODES[@status]
end

def to_a

Returns an Array ala Rack: `[status, headers, body]`
def to_a
  [status, headers.to_h, body.to_s]
end

def to_s

Return the response body as a string
def to_s
  body.to_s
end