protocol-http2 0.13.1 → 0.14.2

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: 62e14f9b0bcdddd080367d473e9241575553bab2bb4839c87d8151ff64e0c3fa
4
- data.tar.gz: 6683dd38d00845b4548271032bd3d427c563f4440b72bbec7a4f1083ae850cfc
3
+ metadata.gz: c08e3a01dc017b795d02fbe0c0d40ba55afb475952309edb0e0a76146a9e6f3b
4
+ data.tar.gz: c493a5e2bcd50eae781baaa83a7a01224a09227490aeb5e1472a1f2c7f017181
5
5
  SHA512:
6
- metadata.gz: b2e9e50a727eb8e7139b498e3accd1b63bc96d4ba30f534add1052f9ea45b5d5a42f24b7efc44a7edf97b473ec13433a98b3a52af77582033d7953e9907aa3da
7
- data.tar.gz: ab63ce654af74f7d13373a9510e8fb070fd8ef031bc6dbae20295a9022a6ed93c7cf7c7db1ef8077caabca14c10cc42ecea48579b3df44e0192de1673d47fd5b
6
+ metadata.gz: 32ddc91c1bcb1396305760e956291cbaa199af6cbd84026c102d0860c0fa852c232cceb1f9561758ea73fa2902ac525045411a9e2dd02297b35643f2349b5993
7
+ data.tar.gz: b00bf59cf1e91b5464960b0e6848e67a96653e48a9739985c9c03070c8d66c5d18067d5e9db38c904447ce696d57766493f656c22b35490363cf73d703867306
@@ -99,8 +99,9 @@ module Protocol
99
99
  # The highest stream_id that has been successfully accepted by this connection.
100
100
  attr :remote_stream_id
101
101
 
102
+ # Whether the connection is effectively or actually closed.
102
103
  def closed?
103
- @state == :closed
104
+ @state == :closed || @framer.nil?
104
105
  end
105
106
 
106
107
  def delete(id)
@@ -112,9 +113,12 @@ module Protocol
112
113
  def close(error = nil)
113
114
  # The underlying socket may already be closed by this point.
114
115
  @streams.each_value{|stream| stream.close(error)}
116
+ @streams.clear
115
117
 
116
- @framer.close
117
- @framer = nil
118
+ if @framer
119
+ @framer.close
120
+ @framer = nil
121
+ end
118
122
  end
119
123
 
120
124
  def encode_headers(headers, buffer = String.new.b)
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Protocol
22
22
  module HTTP2
23
- VERSION = "0.13.1"
23
+ VERSION = "0.14.2"
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.13.1
4
+ version: 0.14.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-03 00:00:00.000000000 Z
11
+ date: 2021-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: protocol-hpack
@@ -30,30 +30,16 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.15'
33
+ version: '0.18'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.15'
40
+ version: '0.18'
41
41
  - !ruby/object:Gem::Dependency
42
- name: covered
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: bake-bundler
42
+ name: bundler
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - ">="
@@ -67,7 +53,7 @@ dependencies:
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
- name: bundler
56
+ name: covered
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - ">="
@@ -94,20 +80,12 @@ dependencies:
94
80
  - - "~>"
95
81
  - !ruby/object:Gem::Version
96
82
  version: '3.0'
97
- description:
83
+ description:
98
84
  email:
99
- - samuel.williams@oriontransfer.co.nz
100
85
  executables: []
101
86
  extensions: []
102
87
  extra_rdoc_files: []
103
88
  files:
104
- - ".gitignore"
105
- - ".rspec"
106
- - ".travis.yml"
107
- - Gemfile
108
- - README.md
109
- - examples/http2/request.rb
110
- - examples/http2/requests.rb
111
89
  - lib/protocol/http2.rb
112
90
  - lib/protocol/http2/client.rb
113
91
  - lib/protocol/http2/connection.rb
@@ -130,18 +108,17 @@ files:
130
108
  - lib/protocol/http2/stream.rb
131
109
  - lib/protocol/http2/version.rb
132
110
  - lib/protocol/http2/window_update_frame.rb
133
- - protocol-http2.gemspec
134
111
  homepage: https://github.com/socketry/protocol-http2
135
112
  licenses:
136
113
  - MIT
137
114
  metadata: {}
138
- post_install_message:
115
+ post_install_message:
139
116
  rdoc_options: []
140
117
  require_paths:
141
118
  - lib
142
119
  required_ruby_version: !ruby/object:Gem::Requirement
143
120
  requirements:
144
- - - "~>"
121
+ - - ">="
145
122
  - !ruby/object:Gem::Version
146
123
  version: '2.5'
147
124
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -151,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
128
  version: '0'
152
129
  requirements: []
153
130
  rubygems_version: 3.1.2
154
- signing_key:
131
+ signing_key:
155
132
  specification_version: 4
156
133
  summary: A low level implementation of the HTTP/2 protocol.
157
134
  test_files: []
data/.gitignore DELETED
@@ -1,13 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
12
- Gemfile.lock
13
- .covered.db
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --warnings
3
- --require spec_helper
@@ -1,22 +0,0 @@
1
- language: ruby
2
- dist: xenial
3
- cache: bundler
4
-
5
- script: bundle exec rspec
6
-
7
- matrix:
8
- include:
9
- - rvm: 2.5
10
- - rvm: 2.6
11
- - rvm: 2.7
12
- - rvm: 2.6
13
- env: COVERAGE=PartialSummary,Coveralls
14
- - rvm: 2.7
15
- - rvm: truffleruby
16
- - rvm: jruby-head
17
- env: JRUBY_OPTS="--debug -X+O"
18
- - rvm: ruby-head
19
- allow_failures:
20
- - rvm: truffleruby
21
- - rvm: ruby-head
22
- - rvm: jruby-head
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in protocol-http2.gemspec
4
- gemspec
data/README.md DELETED
@@ -1,120 +0,0 @@
1
- # Protocol::HTTP2
2
-
3
- Provides a low-level implementation of the HTTP/2 protocol.
4
-
5
- [![Build Status](https://travis-ci.com/socketry/protocol-http2.svg?branch=master)](https://travis-ci.com/socketry/protocol-http2?branch=master)
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'protocol-http2'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install protocol-http2
22
-
23
- ## Usage
24
-
25
- Here is a basic HTTP/2 client:
26
-
27
- ```ruby
28
- require 'async'
29
- require 'async/io/stream'
30
- require 'async/http/endpoint'
31
- require 'protocol/http2/client'
32
-
33
- Async do
34
- endpoint = Async::HTTP::Endpoint.parse("https://www.google.com/search?q=kittens")
35
-
36
- peer = endpoint.connect
37
-
38
- puts "Connected to #{peer.inspect}"
39
-
40
- # IO Buffering...
41
- stream = Async::IO::Stream.new(peer)
42
-
43
- framer = Protocol::HTTP2::Framer.new(stream)
44
- client = Protocol::HTTP2::Client.new(framer)
45
-
46
- puts "Sending connection preface..."
47
- client.send_connection_preface
48
-
49
- puts "Creating stream..."
50
- stream = client.create_stream
51
-
52
- headers = [
53
- [":scheme", endpoint.scheme],
54
- [":method", "GET"],
55
- [":authority", "www.google.com"],
56
- [":path", endpoint.path],
57
- ["accept", "*/*"],
58
- ]
59
-
60
- puts "Sending request on stream id=#{stream.id} state=#{stream.state}..."
61
- stream.send_headers(nil, headers, Protocol::HTTP2::END_STREAM)
62
-
63
- puts "Waiting for response..."
64
- $count = 0
65
-
66
- def stream.process_headers(frame)
67
- headers = super
68
- puts "Got response headers: #{headers} (#{frame.end_stream?})"
69
- end
70
-
71
- def stream.receive_data(frame)
72
- data = super
73
-
74
- $count += data.scan(/kittens/).count
75
-
76
- puts "Got response data: #{data.bytesize}"
77
- end
78
-
79
- until stream.closed?
80
- frame = client.read_frame
81
- end
82
-
83
- puts "Got #{$count} kittens!"
84
-
85
- puts "Closing client..."
86
- client.close
87
- end
88
- ```
89
-
90
- ## Contributing
91
-
92
- 1. Fork it
93
- 2. Create your feature branch (`git checkout -b my-new-feature`)
94
- 3. Commit your changes (`git commit -am 'Add some feature'`)
95
- 4. Push to the branch (`git push origin my-new-feature`)
96
- 5. Create new Pull Request
97
-
98
- ## License
99
-
100
- Released under the MIT license.
101
-
102
- Copyright, 2019, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
103
-
104
- Permission is hereby granted, free of charge, to any person obtaining a copy
105
- of this software and associated documentation files (the "Software"), to deal
106
- in the Software without restriction, including without limitation the rights
107
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
108
- copies of the Software, and to permit persons to whom the Software is
109
- furnished to do so, subject to the following conditions:
110
-
111
- The above copyright notice and this permission notice shall be included in
112
- all copies or substantial portions of the Software.
113
-
114
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
115
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
116
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
117
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
118
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
119
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
120
- THE SOFTWARE.
@@ -1,65 +0,0 @@
1
-
2
- $LOAD_PATH.unshift File.expand_path("../../lib", __dir__)
3
-
4
- require 'async'
5
- require 'async/io/stream'
6
- require 'async/http/endpoint'
7
- require 'protocol/http2/client'
8
-
9
- Async do
10
- endpoint = Async::HTTP::Endpoint.parse("https://www.google.com/search?q=kittens")
11
-
12
- peer = endpoint.connect
13
-
14
- puts "Connected to #{peer.inspect}"
15
-
16
- # IO Buffering...
17
- stream = Async::IO::Stream.new(peer)
18
-
19
- framer = Protocol::HTTP2::Framer.new(stream)
20
- client = Protocol::HTTP2::Client.new(framer)
21
-
22
- puts "Sending connection preface..."
23
- client.send_connection_preface
24
-
25
- puts "Creating stream..."
26
- stream = client.create_stream
27
-
28
- headers = [
29
- [":scheme", endpoint.scheme],
30
- [":method", "GET"],
31
- [":authority", "www.google.com"],
32
- [":path", endpoint.path],
33
- ["accept", "*/*"],
34
- ]
35
-
36
- puts "Sending request on stream id=#{stream.id} state=#{stream.state}..."
37
- stream.send_headers(nil, headers, Protocol::HTTP2::END_STREAM)
38
-
39
- puts "Waiting for response..."
40
- $count = 0
41
-
42
- def stream.process_headers(frame)
43
- headers = super
44
- puts "Got response headers: #{headers} (#{frame.end_stream?})"
45
- end
46
-
47
- def stream.receive_data(frame)
48
- data = super
49
-
50
- $count += data.scan(/kittens/).size
51
-
52
- puts "Got response data: #{data.bytesize}"
53
- end
54
-
55
- until stream.closed?
56
- frame = client.read_frame
57
- end
58
-
59
- puts "Got #{$count} kittens!"
60
-
61
- puts "Closing client..."
62
- client.close
63
- end
64
-
65
- puts "Exiting."
@@ -1,56 +0,0 @@
1
-
2
- $LOAD_PATH.unshift File.expand_path("../../lib", __dir__)
3
-
4
- require 'async'
5
- require 'async/io/stream'
6
- require 'async/http/endpoint'
7
- require 'protocol/http2/client'
8
-
9
- queries = ["apple", "orange", "teapot", "async"]
10
-
11
- Async do
12
- endpoint = Async::HTTP::Endpoint.parse("https://www.google.com")
13
-
14
- peer = endpoint.connect
15
- stream = Async::IO::Stream.new(peer)
16
- framer = Protocol::HTTP2::Framer.new(stream)
17
- client = Protocol::HTTP2::Client.new(framer)
18
-
19
- puts "Sending connection preface..."
20
- client.send_connection_preface
21
-
22
- puts "Creating stream..."
23
- streams = queries.collect do |keyword|
24
- client.create_stream.tap do |stream|
25
- headers = [
26
- [":scheme", endpoint.scheme],
27
- [":method", "GET"],
28
- [":authority", "www.google.com"],
29
- [":path", "/search?q=#{keyword}"],
30
- ["accept", "*/*"],
31
- ]
32
-
33
- puts "Sending request on stream id=#{stream.id} state=#{stream.state}..."
34
- stream.send_headers(nil, headers, Protocol::HTTP2::END_STREAM)
35
-
36
- def stream.process_headers(frame)
37
- headers = super
38
- puts "Stream #{self.id}: Got response headers: #{headers} (#{frame.end_stream?})"
39
- end
40
-
41
- def stream.receive_data(frame)
42
- data = super
43
- puts "Stream #{self.id}: Got response data: #{data.bytesize}"
44
- end
45
- end
46
- end
47
-
48
- until streams.all?{|stream| stream.closed?}
49
- frame = client.read_frame
50
- end
51
-
52
- puts "Closing client..."
53
- client.close
54
- end
55
-
56
- puts "Exiting."
@@ -1,30 +0,0 @@
1
-
2
- require_relative "lib/protocol/http2/version"
3
-
4
- Gem::Specification.new do |spec|
5
- spec.name = "protocol-http2"
6
- spec.version = Protocol::HTTP2::VERSION
7
- spec.authors = ["Samuel Williams"]
8
- spec.email = ["samuel.williams@oriontransfer.co.nz"]
9
-
10
- spec.summary = "A low level implementation of the HTTP/2 protocol."
11
- spec.homepage = "https://github.com/socketry/protocol-http2"
12
- spec.license = "MIT"
13
-
14
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
15
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
- end
17
-
18
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
- spec.require_paths = ["lib"]
20
-
21
- spec.required_ruby_version = '~> 2.5'
22
-
23
- spec.add_dependency "protocol-hpack", "~> 1.4"
24
- spec.add_dependency "protocol-http", "~> 0.15"
25
-
26
- spec.add_development_dependency "covered"
27
- spec.add_development_dependency "bake-bundler"
28
- spec.add_development_dependency "bundler"
29
- spec.add_development_dependency "rspec", "~> 3.0"
30
- end