class
HTTP2::Connection
- HTTP2::Connection
- Reference
- Object
Defined in:
connection.crConstructors
Instance Method Summary
-
#close(error : Error | Nil = nil, notify : Bool = true)
Terminates the HTTP/2 connection.
- #closed? : Bool
-
#local_settings : Settings
Local settings.
-
#read_client_preface(truncated = false) : Nil
Reads the expected
HTTP2::CLIENT_PREFACEfor a server context. -
#receive : Frame | Nil
Call in the main loop to receive individual frames.
-
#remote_settings : Settings
Settings of remote peer.
-
#send(frame : Frame | Array(Frame)) : Nil
Sends a frame to the connected peer.
-
#send_settings : Nil
Sends a SETTINGS frame for the current
#local_settingsvalues. - #streams : Streams
-
#write_client_preface : Nil
Writes the
HTTP2::CLIENT_PREFACEto initialize an HTTP/2 client connection. -
#write_settings : Nil
Immediately writes local settings to the connection.
Constructor Detail
Instance Method Detail
Terminates the HTTP/2 connection.
This will send a GOAWAY frame if notify is true, reporting an
Error::Code optional message if present to report an error, or
Error::Code::NO_ERROR to terminate the connection cleanly.
NOTE doesn't close the IO, only the HTTP/2 connection.
Local settings. You may tune local settings prior to establishing the
connection (prior to #write_settings) or later on, in which case you
must call #send_settings to report changes to the remote peer.
Reads the expected HTTP2::CLIENT_PREFACE for a server context.
You may set truncated to true if the request line was already read, for
example when trying to figure out whether the request was a HTTP/1 or
HTTP/2 direct request, where "PRI * HTTP/2.0\r\n" was already consumed.
Call in the main loop to receive individual frames.
Most frames are already being taken care of, so only HEADERS, DATA or PUSH_PROMISE frames should really be interesting. Other frames can be ignored safely.
Unknown frame types are reported with a raw Frame#payload, so a client
or server may handle them (e.g. custom extensions). They can be safely
ignored.
Settings of remote peer. Updated whenever a SETTINGS frame is received.
Sends a frame to the connected peer.
One may also send an Array(Frame) for the case when some frames must be sliced (in order to respect max frame size) but must be sent as a single block (multiplexing would cause a protocol error).
So far this only applies to HEADERS (and PUSH_PROMISE) and CONTINUATION frames, otherwise HPACK compression synchronisation could end up corrupted if another HEADERS frame for another stream was sent in between.
Writes the HTTP2::CLIENT_PREFACE to initialize an HTTP/2 client
connection.
Immediately writes local settings to the connection.
This is UNSAFE and MUST only be called for sending the initial SETTINGS
frame. Sending changes to #local_settings once the connection
established MUST use #send_settings instead!