class

HTTP2::Stream

Inherits Reference < Object

Instance methods

==(other : Stream)
Source
==(other)

Returns false (other can only be a Value here).

Source
active?

Returns true if the stream is in an active #state, that is OPEN or HALF_CLOSED (local or remote).

Source
data

Received body.

Implemented as a circular buffer that acts as an IO. Reading a request body will block if the buffer is emptied, and will be resumed when the connected peer sends more DATA frames.

See Data for more details.

Source
headers

Received HTTP headers. In a server context they are headers of the received client request; in a client context they are headers of the received server response.

Source
id

The stream identifier. Odd-numbered for client streams (requests), even-numbered for server initiated streams (server-push).

Source
priority
Source
priority=(priority : Priority)
Source
send_data(data : String, flags : Frame::Flags = Frame::Flags::None) : Nil

Writes data to the stream.

This may be part of a request body (client context), or a response body (server context).

This will send one or many DATA frames, respecting SETTINGS_MAX_FRAME_SIZE as defined by the remote peer, as well as available window sizes for the stream and the connection, exhausting them as much as possible.

This will block the current fiber if data is too big than allowed by any window size (stream or connection). The fiber will be eventually resumed when the remote peer sends a WINDOW_UPDATE frame to increment window sizes.

Eventually returns when data has been fully sent.

Source
send_data(data : Bytes, flags : Frame::Flags = Frame::Flags::None) : Nil

ditto

Source
send_headers(headers : HTTP::Headers, flags : Frame::Flags = Frame::Flags::None) : Nil

Sends HTTP::Headers as part of a response or request.

This will send a HEADERS frame, possibly followed by CONTINUATION frames. The Frame::Flags::END_HEADERS flag will be automatically set on the last part; hence you can't send headers multiple times.

Source
send_priority

Sends a PRIORITY frame for the current #priority definition.

This may only be sent by a client, to hint the server to prioritize some streams over others. The server may or may not respect the expected priorities.

Source
send_push_promise(headers : HTTP::Headers, flags : Frame::Flags = Frame::Flags::None) : Stream | Nil

Sends HTTP::Headers as a server-push request.

Creates a server initiated stream (even numbered) as the promised stream, that is the stream that shall be used to push the server-pushed response headers and data.

This will send a PUSH_PROMISE frame to the expected stream. If the client doesn't want the server-push or already has it cached, it may refuse the server-push request by closing the promised stream immediately.

Returns the promised stream, or nil if the client configured SETTINGS_ENABLE_PUSH to be false (true by default).

You may send multiple PUSH_PROMISE frames on an expected stream, but you may send only one per resource to push.

Source
send_rst_stream(error_code : Error::Code) : Nil

Closes the stream. Optionally reporting an error status.

Source
state
Source
trailers?

Received trailing HTTP headers, or nil if none have been received (yet).

Source

Nested types