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.

<std:http>:2315

Methods

def status -> Int

The status code.

<std:http>:2317

def version -> String

"HTTP/1.1" or "HTTP/1.0".

<std:http>:2319

def headers -> HTTP::Headers

The header fields.

<std:http>:2321

def body -> HTTP::Body

The body (read up to the client's max_body_bytes, each_chunk without a limit).

<std:http>:2324

def url -> URI

The URL that answered: the request's, or where redirects led.

<std:http>:2326

def request -> HTTP::Client::Request

The last request sent.

<std:http>:2328

def to_h -> Hash[Symbol, Object]

The fields as a Hash, by name.

<std:http>:2331

def reason -> String

The reason phrase of the status ("OK"), as this client knows it.

<std:http>:2331

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.

<std:http>:2331

def success? -> Bool

Whether the status is 2xx.

<std:http>:2334

def redirect? -> Bool

Whether it is a redirect the client follows (301, 302, 303, 307, 308).

<std:http>:2338

def ensure_success -> HTTP::Client::Response

The response itself when it is 2xx; otherwise StatusError, with its status, headers, URL and body (read here).

<std:http>:2342

def json -> JSON::Value

The body parsed as JSON (JSON.parse(body.read)).

<std:http>:2353

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.

<std:http>:2358