class

Halite::Response

Inherits Reference / Object

Constructors

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)
Source

Instance methods

body(*args, **options)
Source
body(*args, **options, &)
Source
body_io(*args, **options)
Source
body_io(*args, **options, &)
Source
charset(*args, **options)
Source
charset(*args, **options, &)
Source
conn
Source
content_length

Content Length

Source
content_type(*args, **options)
Source
content_type(*args, **options, &)
Source
cookies

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

Source
filename

Return filename if it exists, else Nil.

Source
headers(*args, **options)
Source
headers(*args, **options, &)
Source
history
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
parse(name : String | Nil = nil)

Parse response body with corresponding MIME type adapter.

Source
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
Source
rate_limit
Source
status_code(*args, **options)
Source
status_code(*args, **options, &)
Source
status_message(*args, **options)
Source
status_message(*args, **options, &)
Source
success?(*args, **options)
Source
success?(*args, **options, &)
Source
to_a

Return status_code, headers and body in a array

Source
to_raw

Return raw of response

Source
to_s(io)
Source
to_s

Return String eagerly consume the entire body as a string

Source
version(*args, **options)
Source
version(*args, **options, &)
Source