class HTTP2::Stream

Defined in:

stream.cr

Instance Method Summary

Instance Method Detail

def ==(other : Stream) #

[View source]
def ==(other) #
Description copied from class Reference

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


[View source]
def active? : Bool #

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


[View source]
def data : 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.


[View source]
def headers : HTTP::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.


[View source]
def id : Int32 #

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


[View source]
def priority : Priority #

[View source]
def priority=(priority : Priority) #

[View source]
def 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.


[View source]
def send_data(data : Bytes, flags : Frame::Flags = Frame::Flags::None) : Nil #

ditto


[View source]
def 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.


[View source]
def send_priority : Nil #

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.


[View source]
def 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.


[View source]
def send_rst_stream(error_code : Error::Code) : Nil #

Closes the stream. Optionally reporting an error status.


[View source]
def state : State #

[View source]
def trailers? : HTTP::Headers | Nil #

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


[View source]