class Protocol::HTTP2::Server
connection preface handling, and settings negotiation.
Manages server-side protocol semantics including stream ID allocation,
Represents an HTTP/2 server connection.
def accept_push_promise_stream(stream_id, &block)
@parameter stream_id [Integer] The stream ID (unused).
Servers cannot accept push promise streams from clients.
def accept_push_promise_stream(stream_id, &block) raise ProtocolError, "Cannot accept push promises on server!" end
def enable_push?
Check if server push is enabled by the client.
def enable_push? @remote_settings.enable_push? end
def initialize(framer)
Initialize a new HTTP/2 server connection.
def initialize(framer) super(framer, 2) end
def local_stream_id?(id)
@parameter id [Integer] The stream ID to check.
Server streams have even numbered IDs.
Check if the given stream ID represents a locally-initiated stream.
def local_stream_id?(id) id.even? end
def read_connection_preface(settings = [])
@parameter settings [Array] Optional settings to send during preface exchange.
This must be called once when the connection is first established.
Read the HTTP/2 connection preface from the client and send initial settings.
def read_connection_preface(settings = []) if @state == :new @framer.read_connection_preface send_settings(settings) read_frame do |frame| unless frame.is_a? SettingsFrame raise ProtocolError, "First frame must be #{SettingsFrame}, but got #{frame.class}" end end else raise ProtocolError, "Cannot read connection preface in state #{@state}" end end
def remote_stream_id?(id)
@parameter id [Integer] The stream ID to check.
Client streams have odd numbered IDs.
Check if the given stream ID represents a remotely-initiated stream.
def remote_stream_id?(id) id.odd? end
def valid_remote_stream_id?(stream_id)
@parameter stream_id [Integer] The stream ID to validate.
Client-initiated streams must have odd numbered IDs.
Check if the given stream ID is valid for remote initiation.
def valid_remote_stream_id?(stream_id) stream_id.odd? end