protocol-http2 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +2 -2
- data/examples/http2/request.rb +2 -2
- data/examples/http2/requests.rb +2 -2
- data/lib/protocol/http2/connection.rb +4 -2
- data/lib/protocol/http2/framer.rb +4 -0
- data/lib/protocol/http2/settings_frame.rb +24 -2
- data/lib/protocol/http2/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aea99dc493ccb40d8116646387ff26724010de491bd248e8d925d0dead5d60d3
|
4
|
+
data.tar.gz: 1ee5cb421bfd1674181ddf079534bf793c69ae328bbd1e80fe7ab7a154cca9f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6bae8dd0f45b18b0430158c844ef4c6eddc0a5b6233215663f61c9628021a4213f1d1e2cfa6dede159845f3216d27b25dba47e78b51cfa7fcacf56fc8c08cfb
|
7
|
+
data.tar.gz: 43d2b449bad3864708bcb68219999ecc058f633c2866d73331c09d1bb7c2f2ab9c4922313b6124f239bf19a8dc38d4c26638aa7c3563fd9fada4dfe29374bc2b
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -27,12 +27,12 @@ Here is a basic HTTP/2 client:
|
|
27
27
|
```ruby
|
28
28
|
require 'async'
|
29
29
|
require 'async/io/stream'
|
30
|
-
require 'async/http/
|
30
|
+
require 'async/http/endpoint'
|
31
31
|
require 'protocol/http2/client'
|
32
32
|
require 'pry'
|
33
33
|
|
34
34
|
Async.run do
|
35
|
-
endpoint = Async::HTTP::
|
35
|
+
endpoint = Async::HTTP::Endpoint.parse("https://www.google.com/search?q=kittens")
|
36
36
|
|
37
37
|
peer = endpoint.connect
|
38
38
|
|
data/examples/http2/request.rb
CHANGED
@@ -3,12 +3,12 @@ $LOAD_PATH.unshift File.expand_path("../../lib", __dir__)
|
|
3
3
|
|
4
4
|
require 'async'
|
5
5
|
require 'async/io/stream'
|
6
|
-
require 'async/http/
|
6
|
+
require 'async/http/endpoint'
|
7
7
|
require 'protocol/http2/client'
|
8
8
|
require 'pry'
|
9
9
|
|
10
10
|
Async.run do
|
11
|
-
endpoint = Async::HTTP::
|
11
|
+
endpoint = Async::HTTP::Endpoint.parse("https://www.google.com/search?q=kittens")
|
12
12
|
|
13
13
|
peer = endpoint.connect
|
14
14
|
|
data/examples/http2/requests.rb
CHANGED
@@ -3,14 +3,14 @@ $LOAD_PATH.unshift File.expand_path("../../lib", __dir__)
|
|
3
3
|
|
4
4
|
require 'async'
|
5
5
|
require 'async/io/stream'
|
6
|
-
require 'async/http/
|
6
|
+
require 'async/http/endpoint'
|
7
7
|
require 'protocol/http2/client'
|
8
8
|
require 'pry'
|
9
9
|
|
10
10
|
queries = ["apple", "orange", "teapot", "async"]
|
11
11
|
|
12
12
|
Async.run do
|
13
|
-
endpoint = Async::HTTP::
|
13
|
+
endpoint = Async::HTTP::Endpoint.parse("https://www.google.com")
|
14
14
|
|
15
15
|
peer = endpoint.connect
|
16
16
|
stream = Async::IO::Stream.new(peer)
|
@@ -79,7 +79,9 @@ module Protocol
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def close
|
82
|
-
|
82
|
+
return if @framer.closed?
|
83
|
+
|
84
|
+
send_goaway unless closed?
|
83
85
|
|
84
86
|
@framer.close
|
85
87
|
end
|
@@ -153,7 +155,7 @@ module Protocol
|
|
153
155
|
last_stream_id, error_code, message = frame.unpack
|
154
156
|
|
155
157
|
if error_code != 0
|
156
|
-
raise GoawayError.new
|
158
|
+
raise GoawayError.new(message, error_code)
|
157
159
|
end
|
158
160
|
end
|
159
161
|
|
@@ -29,6 +29,7 @@ module Protocol
|
|
29
29
|
INITIAL_WINDOW_SIZE = 0x4
|
30
30
|
MAXIMUM_FRAME_SIZE = 0x5
|
31
31
|
MAXIMUM_HEADER_LIST_SIZE = 0x6
|
32
|
+
ENABLE_CONNECT_PROTOCOL = 0x8
|
32
33
|
|
33
34
|
# Allows the sender to inform the remote endpoint of the maximum size of the header compression table used to decode header blocks, in octets.
|
34
35
|
attr_accessor :header_table_size
|
@@ -37,7 +38,7 @@ module Protocol
|
|
37
38
|
attr :enable_push
|
38
39
|
|
39
40
|
def enable_push= value
|
40
|
-
if
|
41
|
+
if value == 0 or value == 1
|
41
42
|
@enable_push = value
|
42
43
|
else
|
43
44
|
raise ProtocolError, "Invalid value for enable_push: #{value}"
|
@@ -45,7 +46,7 @@ module Protocol
|
|
45
46
|
end
|
46
47
|
|
47
48
|
def enable_push?
|
48
|
-
@enable_push
|
49
|
+
@enable_push == 1
|
49
50
|
end
|
50
51
|
|
51
52
|
# Indicates the maximum number of concurrent streams that the sender will allow.
|
@@ -77,6 +78,20 @@ module Protocol
|
|
77
78
|
# This advisory setting informs a peer of the maximum size of header list that the sender is prepared to accept, in octets.
|
78
79
|
attr_accessor :maximum_header_list_size
|
79
80
|
|
81
|
+
attr :enable_connect_protocol
|
82
|
+
|
83
|
+
def enable_connect_protocol= value
|
84
|
+
if value == 0 or value == 1
|
85
|
+
@enable_connect_protocol = value
|
86
|
+
else
|
87
|
+
raise ProtocolError, "Invalid value for enable_connect_protocol: #{value}"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def enable_connect_protocol?
|
92
|
+
@enable_connect_protocol == 1
|
93
|
+
end
|
94
|
+
|
80
95
|
def initialize
|
81
96
|
# These limits are taken from the RFC:
|
82
97
|
# https://tools.ietf.org/html/rfc7540#section-6.5.2
|
@@ -86,6 +101,7 @@ module Protocol
|
|
86
101
|
@initial_window_size = 0xFFFF # 2**16 - 1
|
87
102
|
@maximum_frame_size = 0x4000 # 2**14
|
88
103
|
@maximum_header_list_size = 0xFFFFFFFF
|
104
|
+
@enable_connect_protocol = 0
|
89
105
|
end
|
90
106
|
|
91
107
|
ASSIGN = [
|
@@ -96,6 +112,8 @@ module Protocol
|
|
96
112
|
:initial_window_size=,
|
97
113
|
:maximum_frame_size=,
|
98
114
|
:maximum_header_list_size=,
|
115
|
+
nil, nil,
|
116
|
+
:enable_connect_protocol=,
|
99
117
|
]
|
100
118
|
|
101
119
|
def update(changes)
|
@@ -133,6 +151,10 @@ module Protocol
|
|
133
151
|
changes << [MAXIMUM_HEADER_LIST_SIZE, @maximum_header_list_size]
|
134
152
|
end
|
135
153
|
|
154
|
+
if @enable_connect_protocol != other.enable_connect_protocol
|
155
|
+
changes << [ENABLE_CONNECT_PROTOCOL, @enable_connect_protocol]
|
156
|
+
end
|
157
|
+
|
136
158
|
return changes
|
137
159
|
end
|
138
160
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protocol-http2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: protocol-hpack
|