data HTTP::Client::Response(status: Int, version: String, headers: HTTP::Headers, body: HTTP::Body, url: URI, request: HTTP::Client::Request)
A response: its status and headers, and its body, read from the
connection as it is asked for. The connection goes back to the pool
when the body has been read to its end (body.read, read_bytes,
each_chunk, #close); a response dropped with its body unread
closes its connection.
Methods
def status -> Int
The status code.
def version -> String
"HTTP/1.1" or "HTTP/1.0".
def headers -> HTTP::Headers
The header fields.
def body -> HTTP::Body
The body (read up to the client's max_body_bytes, each_chunk
without a limit).
def url -> URI
The URL that answered: the request's, or where redirects led.
def request -> HTTP::Client::Request
The last request sent.
def to_h -> Hash[Symbol, Object]
The fields as a Hash, by name.
def reason -> String
The reason phrase of the status ("OK"), as this client knows it.
def with(*, status: Int = …, version: String = …, headers: HTTP::Headers = …, body: HTTP::Body = …, url: URI = …, request: HTTP::Client::Request = …) -> HTTP::Client::Response
A copy with the fields given replaced.
def success? -> Bool
Whether the status is 2xx.
def redirect? -> Bool
Whether it is a redirect the client follows (301, 302, 303, 307, 308).
def ensure_success -> HTTP::Client::Response
The response itself when it is 2xx; otherwise StatusError, with
its status, headers, URL and body (read here).
def json -> JSON::Value
The body parsed as JSON (JSON.parse(body.read)).
def close -> Void
Done with the body: what is left is read when it is little (64 KiB), so that the connection can be kept; otherwise the connection is closed.