class Protocol::HTTP2::Connection

def create_stream(id = next_stream_id, &block)

Returns:
  • (Stream) - the created stream.
def create_stream(id = next_stream_id, &block)
	if self.goaway_received? and local_stream_id?(id)
		# Receivers of a GOAWAY frame MUST NOT open additional streams on the connection (RFC 9113 ยง6.8). A new connection has to be established for new streams.
		raise ProtocolError, "Cannot create stream #{id} after GOAWAY!"
	end
	
	if @streams.key?(id)
		raise ProtocolError, "Cannot create stream with id #{id}, already exists!"
	end
	
	if block_given?
		return yield(self, id)
	else
		return Stream.create(self, id)
	end
end