class

HTTP2::Response

Inherits Reference < Object

A streaming HTTP response. Consume or close body before waiting for trailers so flow control can continue.

Instance methods

body
Source
cancel

Cancels the request outright: sends RST_STREAM and fails the stream with a RequestCanceledError, so — unlike #close — a later #body read or #trailers wait raises that same error instead of a generic IO::Error. Safe to call more than once, or after the stream has already closed.

Source
close

Stops consuming the response without attaching a request-specific error. Discards any buffered body bytes (returning their flow-control credit) and, unless the stream already reached a natural end, sends RST_STREAM to cancel it — but does not record a terminal error for that reset: a later #body read raises only a generic IO::Error ("Closed stream"), not a stream's own terminal error, which keeps a caller's own graceful stop distinguishable from #cancel and from a library-initiated reclamation (see Client::Timeouts#idle) by exception type. Safe to call more than once, or after the body has already finished.

Source
headers
Source
informational_responses

The 1xx informational responses seen before the final status, in order. The returned array must be treated as read-only: when a response received none, this may be the shared EMPTY_INFORMATIONAL constant rather than a fresh allocation.

Source
status
Source
stream_id
Source
trailers(timeout : Time::Span | Nil) : Headers

Waits for the response trailer section, aborting the request as soon as timeout elapses with none received -- regardless of any body-read progress made in the meantime. An empty collection means that the response ended without trailers.

Source
trailers

Waits for the response trailer section using the client's configured idle timeout. Each time that timeout elapses, if the body has consumed additional bytes since the previous check, the wait simply re-arms instead of aborting -- mirroring Client#monitor_response's own consumed-bytes check -- so a caller who awaits trailers before draining a large, actively flowing body is not destroyed out from under it (see Client::Timeouts#idle's "a slow-but-active reader is never killed" contract). An empty collection means that the response ended without trailers.

Source