@@ -15,21 +15,25 @@ module Protocol
1515 module HTTP2
1616 VERSION = "HTTP/2"
1717
18+ # @returns [Boolean] Whether the protocol supports bidirectional communication.
1819 def self . bidirectional?
1920 true
2021 end
2122
23+ # @returns [Boolean] Whether the protocol supports trailers.
2224 def self . trailer?
2325 true
2426 end
2527
28+ # The default settings for the client.
2629 CLIENT_SETTINGS = {
2730 ::Protocol ::HTTP2 ::Settings ::ENABLE_PUSH => 0 ,
2831 ::Protocol ::HTTP2 ::Settings ::MAXIMUM_FRAME_SIZE => 0x100000 ,
2932 ::Protocol ::HTTP2 ::Settings ::INITIAL_WINDOW_SIZE => 0x800000 ,
3033 ::Protocol ::HTTP2 ::Settings ::NO_RFC7540_PRIORITIES => 1 ,
3134 }
3235
36+ # The default settings for the server.
3337 SERVER_SETTINGS = {
3438 # We choose a lower maximum concurrent streams to avoid overloading a single connection/thread.
3539 ::Protocol ::HTTP2 ::Settings ::MAXIMUM_CONCURRENT_STREAMS => 128 ,
@@ -39,6 +43,10 @@ def self.trailer?
3943 ::Protocol ::HTTP2 ::Settings ::NO_RFC7540_PRIORITIES => 1 ,
4044 }
4145
46+ # Create a client for an outbound connection.
47+ #
48+ # @parameter peer [IO] The peer to communicate with.
49+ # @parameter options [Hash] Options to pass to the client instance.
4250 def self . client ( peer , settings : CLIENT_SETTINGS )
4351 stream = ::IO ::Stream ( peer )
4452 client = Client . new ( stream )
@@ -49,6 +57,10 @@ def self.client(peer, settings: CLIENT_SETTINGS)
4957 return client
5058 end
5159
60+ # Create a server for an inbound connection.
61+ #
62+ # @parameter peer [IO] The peer to communicate with.
63+ # @parameter options [Hash] Options to pass to the server instance.
5264 def self . server ( peer , settings : SERVER_SETTINGS )
5365 stream = ::IO ::Stream ( peer )
5466 server = Server . new ( stream )
@@ -59,6 +71,7 @@ def self.server(peer, settings: SERVER_SETTINGS)
5971 return server
6072 end
6173
74+ # @returns [Array] The names of the supported protocol.
6275 def self . names
6376 [ "h2" ]
6477 end
0 commit comments