class

Crest::Response

Inherits Reference < Object

Response objects have several useful methods:

  • body: The response body as a String
  • body_io: The response body as a IO
  • status: The response status as a HTTP::Status
  • status_code: The HTTP response code
  • headers: A hash of HTTP response headers
  • cookies: A hash of HTTP cookies set by the server
  • request: The Crest::Request object used to make the request
  • http_client_res: The HTTP::Client::Response object
  • history: A list of each response received in a redirection chain

Constructors

new(http_client_res : HTTP::Client::Response, request : Crest::Request)
Source

Instance methods

body(*args, **options)
Source
body(*args, **options, &)
Source
body_io(*args, **options)
Source
body_io(*args, **options, &)
Source
client_error?(*args, **options)
Source
client_error?(*args, **options, &)
Source
content_length

Size of the message body in bytes taken from "Content-Length" header

Source
cookies
Source
filename

Extracts filename from "Content-Disposition" header

Source
headers
Source
history
Source
http_client_res
Source
informational?(*args, **options)
Source
informational?(*args, **options, &)
Source
inspect

Returns an unambiguous and information-rich string representation of this object, typically intended for developers.

This method should usually not be overridden. It delegates to #inspect(IO) which can be overridden for custom implementations.

Also see #to_s.

Source
invalid?
Source
redirect?
Source
redirection?(*args, **options)
Source
redirection?(*args, **options, &)
Source
request
Source
return!
Source
return!
Source
server_error?(*args, **options)
Source
server_error?(*args, **options, &)
Source
status(*args, **options)
Source
status(*args, **options, &)
Source
status_code(*args, **options)
Source
status_code(*args, **options, &)
Source
success?(*args, **options)
Source
success?(*args, **options, &)
Source
to_curl(*args, **options)
Source
to_curl(*args, **options, &)
Source
to_s(io : IO) : Nil

Appends a short String representation of this object which includes its class name and its object address.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).to_s # => #<Person:0x10a199f20>
Source