class Halite::Response

Defined in:

halite/response.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(uri : URI, status_code : Int32, body : String | Nil = nil, headers = HTTP::Headers.new, status_message = nil, body_io : IO | Nil = nil, version = "HTTP/1.1", history = [] of Halite::Response) #

[View source]
def self.new(uri : URI, conn : HTTP::Client::Response, history : Array(Halite::Response) = [] of Halite::Response) #

[View source]

Instance Method Detail

def body(*args, **options) #

[View source]
def body(*args, **options, &) #

[View source]
def body_io(*args, **options) #

[View source]
def body_io(*args, **options, &) #

[View source]
def charset(*args, **options) #

[View source]
def charset(*args, **options, &) #

[View source]
def conn : HTTP::Client::Response #

[View source]
def content_length : Int64 | Nil #

Content Length


[View source]
def content_type(*args, **options) #

[View source]
def content_type(*args, **options, &) #

[View source]
def cookies : HTTP::Cookies | Nil #

Return a HTTP::Cookies of parsed cookie headers or else nil.


[View source]
def filename : String | Nil #

Return filename if it exists, else Nil.


[View source]
def headers(*args, **options) #

[View source]
def headers(*args, **options, &) #

[View source]
def history : Array(Response) #

[View source]
def inspect #
Description copied from class Object

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.


[View source]
def links : Hash(String, Halite::HeaderLink) | Nil #

Return a list of parsed link headers proxies or else nil.


[View source]
def parse(name : String | Nil = nil) #

Parse response body with corresponding MIME type adapter.


[View source]
def raise_for_status #

Raise Halite::ClientError/Halite::ServerError if one occurred.

  • 4XX raise an Halite::ClientError exception
  • 5XX raise an Halite::ServerError exception
  • return nil with other status code
Halite.get("https://httpbin.org/status/404").raise_for_status
# => Unhandled exception: 404 not found error with url: https://httpbin.org/status/404  (Halite::ClientError)

Halite.get("https://httpbin.org/status/500", params: {"foo" => "bar"}).raise_for_status
# => Unhandled exception: 500 internal server error error with url: https://httpbin.org/status/500?foo=bar  (Halite::ServerError)

Halite.get("https://httpbin.org/status/301").raise_for_status
# => nil

[View source]
def rate_limit : Halite::RateLimit | Nil #

[View source]
def status_code(*args, **options) #

[View source]
def status_code(*args, **options, &) #

[View source]
def status_message(*args, **options) #

[View source]
def status_message(*args, **options, &) #

[View source]
def success?(*args, **options) #

[View source]
def success?(*args, **options, &) #

[View source]
def to_a #

Return status_code, headers and body in a array


[View source]
def to_raw #

Return raw of response


[View source]
def to_s(io) #

[View source]
def to_s #

Return String eagerly consume the entire body as a string


[View source]
def uri : URI #

[View source]
def version(*args, **options) #

[View source]
def version(*args, **options, &) #

[View source]