@@ -15,21 +15,25 @@ module Protocol
15
15
module HTTP2
16
16
VERSION = "HTTP/2"
17
17
18
+ # @returns [Boolean] Whether the protocol supports bidirectional communication.
18
19
def self . bidirectional?
19
20
true
20
21
end
21
22
23
+ # @returns [Boolean] Whether the protocol supports trailers.
22
24
def self . trailer?
23
25
true
24
26
end
25
27
28
+ # The default settings for the client.
26
29
CLIENT_SETTINGS = {
27
30
::Protocol ::HTTP2 ::Settings ::ENABLE_PUSH => 0 ,
28
31
::Protocol ::HTTP2 ::Settings ::MAXIMUM_FRAME_SIZE => 0x100000 ,
29
32
::Protocol ::HTTP2 ::Settings ::INITIAL_WINDOW_SIZE => 0x800000 ,
30
33
::Protocol ::HTTP2 ::Settings ::NO_RFC7540_PRIORITIES => 1 ,
31
34
}
32
35
36
+ # The default settings for the server.
33
37
SERVER_SETTINGS = {
34
38
# We choose a lower maximum concurrent streams to avoid overloading a single connection/thread.
35
39
::Protocol ::HTTP2 ::Settings ::MAXIMUM_CONCURRENT_STREAMS => 128 ,
@@ -39,6 +43,10 @@ def self.trailer?
39
43
::Protocol ::HTTP2 ::Settings ::NO_RFC7540_PRIORITIES => 1 ,
40
44
}
41
45
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.
42
50
def self . client ( peer , settings : CLIENT_SETTINGS )
43
51
stream = ::IO ::Stream ( peer )
44
52
client = Client . new ( stream )
@@ -49,6 +57,10 @@ def self.client(peer, settings: CLIENT_SETTINGS)
49
57
return client
50
58
end
51
59
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.
52
64
def self . server ( peer , settings : SERVER_SETTINGS )
53
65
stream = ::IO ::Stream ( peer )
54
66
server = Server . new ( stream )
@@ -59,6 +71,7 @@ def self.server(peer, settings: SERVER_SETTINGS)
59
71
return server
60
72
end
61
73
74
+ # @returns [Array] The names of the supported protocol.
62
75
def self . names
63
76
[ "h2" ]
64
77
end
0 commit comments