class Halite::Response
- Halite::Response
- Reference
- Object
Defined in:
halite/response.crConstructors
- .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)
- .new(uri : URI, conn : HTTP::Client::Response, history : Array(Halite::Response) = [] of Halite::Response)
Instance Method Summary
- #body(*args, **options)
- #body(*args, **options, &)
- #body_io(*args, **options)
- #body_io(*args, **options, &)
- #charset(*args, **options)
- #charset(*args, **options, &)
- #conn : HTTP::Client::Response
-
#content_length : Int64 | Nil
Content Length
- #content_type(*args, **options)
- #content_type(*args, **options, &)
-
#cookies : HTTP::Cookies | Nil
Return a
HTTP::Cookies
of parsed cookie headers or else nil. -
#filename : String | Nil
Return filename if it exists, else
Nil
. - #headers(*args, **options)
- #headers(*args, **options, &)
- #history : Array(Response)
-
#inspect
Returns an unambiguous and information-rich string representation of this object, typically intended for developers.
-
#links : Hash(String, Halite::HeaderLink) | Nil
Return a list of parsed link headers proxies or else nil.
-
#parse(name : String | Nil = nil)
Parse response body with corresponding MIME type adapter.
-
#raise_for_status
Raise
Halite::ClientError
/Halite::ServerError
if one occurred. - #rate_limit : Halite::RateLimit | Nil
- #status_code(*args, **options)
- #status_code(*args, **options, &)
- #status_message(*args, **options)
- #status_message(*args, **options, &)
- #success?(*args, **options)
- #success?(*args, **options, &)
-
#to_a
Return status_code, headers and body in a array
-
#to_raw
Return raw of response
- #to_s(io)
-
#to_s
Return String eagerly consume the entire body as a string
- #uri : URI
- #version(*args, **options)
- #version(*args, **options, &)
Constructor Detail
Instance Method Detail
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
.
Return a list of parsed link headers proxies or else nil.
Raise Halite::ClientError
/Halite::ServerError
if one occurred.
4XX
raise anHalite::ClientError
exception5XX
raise anHalite::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