protocol-http2 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a91f84d5d8130880337a867acb5e6ba54087753f7a7bc4dab7cf6bdad36125c
4
- data.tar.gz: 256472a76b2a51ede88de4797ee5d9b8227b4ef2b9af37303f1afa5428eabf32
3
+ metadata.gz: aea99dc493ccb40d8116646387ff26724010de491bd248e8d925d0dead5d60d3
4
+ data.tar.gz: 1ee5cb421bfd1674181ddf079534bf793c69ae328bbd1e80fe7ab7a154cca9f3
5
5
  SHA512:
6
- metadata.gz: fbb6c26d370e900e5bbbae94ec33b2b9343356890f244413deb0371000263851607d79ad99d66b37223eaaaaca5faa33555b2506e9f3662e99ed57cc178f9a37
7
- data.tar.gz: 711c077f0e940bc49181bd76fe7743db396a98bf246de09e39506c075f22d6fca86a05f7b3314251ccde5d99d75c0f2a1d9d59cb2e18aa9e59d7b4d42fb5caed
6
+ metadata.gz: a6bae8dd0f45b18b0430158c844ef4c6eddc0a5b6233215663f61c9628021a4213f1d1e2cfa6dede159845f3216d27b25dba47e78b51cfa7fcacf56fc8c08cfb
7
+ data.tar.gz: 43d2b449bad3864708bcb68219999ecc058f633c2866d73331c09d1bb7c2f2ab9c4922313b6124f239bf19a8dc38d4c26638aa7c3563fd9fada4dfe29374bc2b
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
12
  Gemfile.lock
13
+ .covered.db
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/url_endpoint'
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::URLEndpoint.parse("https://www.google.com/search?q=kittens")
35
+ endpoint = Async::HTTP::Endpoint.parse("https://www.google.com/search?q=kittens")
36
36
 
37
37
  peer = endpoint.connect
38
38
 
@@ -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/url_endpoint'
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::URLEndpoint.parse("https://www.google.com/search?q=kittens")
11
+ endpoint = Async::HTTP::Endpoint.parse("https://www.google.com/search?q=kittens")
12
12
 
13
13
  peer = endpoint.connect
14
14
 
@@ -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/url_endpoint'
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::URLEndpoint.parse("https://www.google.com")
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
- send_goaway
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 message, error_code
158
+ raise GoawayError.new(message, error_code)
157
159
  end
158
160
  end
159
161
 
@@ -61,6 +61,10 @@ module Protocol
61
61
  @stream.close
62
62
  end
63
63
 
64
+ def closed?
65
+ @stream.closed?
66
+ end
67
+
64
68
  def write_connection_preface
65
69
  @stream.write(CONNECTION_PREFACE_MAGIC)
66
70
  end
@@ -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 @enable_push == 0 || @enable_push == 1
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 != 0
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
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Protocol
22
22
  module HTTP2
23
- VERSION = "0.2.1"
23
+ VERSION = "0.3.0"
24
24
  end
25
25
  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.2.1
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-09 00:00:00.000000000 Z
11
+ date: 2019-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: protocol-hpack