protocol-hpack 1.4.1 → 1.4.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: 775932600bc2c9dac28c2048df0fe77d11003811704412df9cc5158fef9652c9
4
- data.tar.gz: 72805181100f90189d7372603e73833e66389371116fba3e81e97c04cfe8717c
3
+ metadata.gz: 4112fcf37f26e859b92e2bcb4dbcdf7fd3df01a29899ecd445d7d983e74e77b1
4
+ data.tar.gz: fc010fa2660401fbd9f8358eb11c5a74102be25dfdf70c7b2a5e63aa7179f7cb
5
5
  SHA512:
6
- metadata.gz: 18660f1c3bf298d4289a1b21bb56aa5926e7613f47da9da7276ef59171832e548b1bc9642647d970873c9c2672f2c78e40ea604bad72393d7c96896033706f87
7
- data.tar.gz: db4617535a39c2c2b70ae750e4ab4f72a5438ca47f7c1d629f33541fe9cb6886567a438c1fd11bc5be232e399f736e0bf11c9197b2a30cf6ce57924b560f9031
6
+ metadata.gz: a18ffe445efee527b9a656ffe33a9230799ae89e9eab11d1cb6996f296c16b07050527b9c1b65125ca26fadcc980d7d25773342bed269c1bc3f6dff0ff0fb7cc
7
+ data.tar.gz: 3214f7efcc5c4cb450571aaf6ba3f7a08023e5d40096390ec77516412865b0f6a9078e239cd570afb3234fe5f2aa124a44fedb1e94b712e741c82d7943b318e4
@@ -7,6 +7,7 @@ matrix:
7
7
  - rvm: 2.4
8
8
  - rvm: 2.5
9
9
  - rvm: 2.6
10
+ - rvm: 2.7
10
11
  - rvm: 2.6
11
12
  env: COVERAGE=PartialSummary,Coveralls
12
13
  - rvm: truffleruby
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  # Specify your gem's dependencies in protocol-hpack.gemspec
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rspec/core/rake_task"
3
5
 
@@ -4,6 +4,7 @@ require_relative "lib/protocol/hpack/version"
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "protocol-hpack"
6
6
  spec.version = Protocol::HPACK::VERSION
7
+ spec.licenses = ["MIT"]
7
8
  spec.authors = ["Samuel Williams"]
8
9
  spec.email = ["samuel.williams@oriontransfer.co.nz"]
9
10
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  # Copyrigh, 2013, by Ilya Grigorik.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  # Copyrigh, 2013, by Ilya Grigorik.
3
5
  #
@@ -40,72 +42,71 @@ module Protocol
40
42
  # dynamic table as a decoding context.
41
43
  # No other state information is needed.
42
44
  class Context
43
- # @private
44
- # Static table
45
- # - http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-10#appendix-A
45
+ # Static header table.
46
+ # https://tools.ietf.org/html/rfc7541#appendix-A
46
47
  STATIC_TABLE = [
47
- [':authority', ''],
48
- [':method', 'GET'],
49
- [':method', 'POST'],
50
- [':path', '/'],
51
- [':path', '/index.html'],
52
- [':scheme', 'http'],
53
- [':scheme', 'https'],
54
- [':status', '200'],
55
- [':status', '204'],
56
- [':status', '206'],
57
- [':status', '304'],
58
- [':status', '400'],
59
- [':status', '404'],
60
- [':status', '500'],
61
- ['accept-charset', ''],
62
- ['accept-encoding', 'gzip, deflate'],
63
- ['accept-language', ''],
64
- ['accept-ranges', ''],
65
- ['accept', ''],
66
- ['access-control-allow-origin', ''],
67
- ['age', ''],
68
- ['allow', ''],
69
- ['authorization', ''],
70
- ['cache-control', ''],
71
- ['content-disposition', ''],
72
- ['content-encoding', ''],
73
- ['content-language', ''],
74
- ['content-length', ''],
75
- ['content-location', ''],
76
- ['content-range', ''],
77
- ['content-type', ''],
78
- ['cookie', ''],
79
- ['date', ''],
80
- ['etag', ''],
81
- ['expect', ''],
82
- ['expires', ''],
83
- ['from', ''],
84
- ['host', ''],
85
- ['if-match', ''],
86
- ['if-modified-since', ''],
87
- ['if-none-match', ''],
88
- ['if-range', ''],
89
- ['if-unmodified-since', ''],
90
- ['last-modified', ''],
91
- ['link', ''],
92
- ['location', ''],
93
- ['max-forwards', ''],
94
- ['proxy-authenticate', ''],
95
- ['proxy-authorization', ''],
96
- ['range', ''],
97
- ['referer', ''],
98
- ['refresh', ''],
99
- ['retry-after', ''],
100
- ['server', ''],
101
- ['set-cookie', ''],
102
- ['strict-transport-security', ''],
103
- ['transfer-encoding', ''],
104
- ['user-agent', ''],
105
- ['vary', ''],
106
- ['via', ''],
107
- ['www-authenticate', ''],
108
- ].each {|pair| pair.each(&:freeze).freeze}.freeze
48
+ [":authority", ""],
49
+ [":method", "GET"],
50
+ [":method", "POST"],
51
+ [":path", "/"],
52
+ [":path", "/index.html"],
53
+ [":scheme", "http"],
54
+ [":scheme", "https"],
55
+ [":status", "200"],
56
+ [":status", "204"],
57
+ [":status", "206"],
58
+ [":status", "304"],
59
+ [":status", "400"],
60
+ [":status", "404"],
61
+ [":status", "500"],
62
+ ["accept-charset", ""],
63
+ ["accept-encoding", "gzip, deflate"],
64
+ ["accept-language", ""],
65
+ ["accept-ranges", ""],
66
+ ["accept", ""],
67
+ ["access-control-allow-origin", ""],
68
+ ["age", ""],
69
+ ["allow", ""],
70
+ ["authorization", ""],
71
+ ["cache-control", ""],
72
+ ["content-disposition", ""],
73
+ ["content-encoding", ""],
74
+ ["content-language", ""],
75
+ ["content-length", ""],
76
+ ["content-location", ""],
77
+ ["content-range", ""],
78
+ ["content-type", ""],
79
+ ["cookie", ""],
80
+ ["date", ""],
81
+ ["etag", ""],
82
+ ["expect", ""],
83
+ ["expires", ""],
84
+ ["from", ""],
85
+ ["host", ""],
86
+ ["if-match", ""],
87
+ ["if-modified-since", ""],
88
+ ["if-none-match", ""],
89
+ ["if-range", ""],
90
+ ["if-unmodified-since", ""],
91
+ ["last-modified", ""],
92
+ ["link", ""],
93
+ ["location", ""],
94
+ ["max-forwards", ""],
95
+ ["proxy-authenticate", ""],
96
+ ["proxy-authorization", ""],
97
+ ["range", ""],
98
+ ["referer", ""],
99
+ ["refresh", ""],
100
+ ["retry-after", ""],
101
+ ["server", ""],
102
+ ["set-cookie", ""],
103
+ ["strict-transport-security", ""],
104
+ ["transfer-encoding", ""],
105
+ ["user-agent", ""],
106
+ ["vary", ""],
107
+ ["via", ""],
108
+ ["www-authenticate", ""],
109
+ ].each(&:freeze).freeze
109
110
 
110
111
  # Initializes compression context with appropriate client/server defaults and maximum size of the dynamic table.
111
112
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  # Copyrigh, 2013, by Ilya Grigorik.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  # Copyrigh, 2013, by Ilya Grigorik.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  # Copyrigh, 2013, by Ilya Grigorik.
3
5
  #
@@ -24,9 +26,7 @@ require_relative 'error'
24
26
 
25
27
  module Protocol
26
28
  module HPACK
27
- # Implementation of huffman encoding for HPACK
28
- #
29
- # - http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-10
29
+ # Implementation of huffman encoding for HPACK.
30
30
  class Huffman
31
31
  BITS_AT_ONCE = 4
32
32
  EOS = 256
@@ -47,23 +47,25 @@ module Protocol
47
47
  # @param buf [Buffer]
48
48
  # @return [String] binary string
49
49
  # @raise [CompressionError] when Huffman coded string is malformed
50
- def decode(buf)
51
- emit = ''
50
+ def decode(buffer)
51
+ emit = String.new.b
52
52
  state = 0 # start state
53
53
 
54
54
  mask = (1 << BITS_AT_ONCE) - 1
55
- buf.each_byte do |chr|
55
+ buffer.each_byte do |c|
56
56
  (8 / BITS_AT_ONCE - 1).downto(0) do |shift|
57
- branch = (chr >> (shift * BITS_AT_ONCE)) & mask
57
+ branch = (c >> (shift * BITS_AT_ONCE)) & mask
58
+
58
59
  # MACHINE[state] = [final, [transitions]]
59
60
  # [final] unfinished bits so far are prefix of the EOS code.
60
61
  # Each transition is [emit, next]
61
62
  # [emit] character to be emitted on this transition, empty string, or EOS.
62
63
  # [next] next state number.
63
- trans = MACHINE[state][branch]
64
- raise CompressionError, 'Huffman decode error (EOS found)' if trans.first == EOS
65
- emit << trans.first.chr if trans.first
66
- state = trans.last
64
+ value, state = MACHINE[state][branch]
65
+
66
+ raise CompressionError, 'Huffman decode error (EOS found)' if value == EOS
67
+
68
+ emit << value.chr if value
67
69
  end
68
70
  end
69
71
  # Check whether partial input is correctly filled
@@ -73,8 +75,7 @@ module Protocol
73
75
  emit.force_encoding(Encoding::BINARY)
74
76
  end
75
77
 
76
- # Huffman table as specified in
77
- # - http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-10#appendix-B
78
+ # Huffman table as specified in https://tools.ietf.org/html/rfc7541#appendix-B
78
79
  CODES = [
79
80
  [0x1ff8, 13],
80
81
  [0x7fffd8, 23],
@@ -108,97 +109,97 @@ module Protocol
108
109
  [0xffffff9, 28],
109
110
  [0xffffffa, 28],
110
111
  [0xffffffb, 28],
111
- [0x14, 6],
112
+ [0x14, 6],
112
113
  [0x3f8, 10],
113
114
  [0x3f9, 10],
114
115
  [0xffa, 12],
115
116
  [0x1ff9, 13],
116
- [0x15, 6],
117
- [0xf8, 8],
117
+ [0x15, 6],
118
+ [0xf8, 8],
118
119
  [0x7fa, 11],
119
120
  [0x3fa, 10],
120
121
  [0x3fb, 10],
121
- [0xf9, 8],
122
+ [0xf9, 8],
122
123
  [0x7fb, 11],
123
- [0xfa, 8],
124
- [0x16, 6],
125
- [0x17, 6],
126
- [0x18, 6],
127
- [0x0, 5],
128
- [0x1, 5],
129
- [0x2, 5],
130
- [0x19, 6],
131
- [0x1a, 6],
132
- [0x1b, 6],
133
- [0x1c, 6],
134
- [0x1d, 6],
135
- [0x1e, 6],
136
- [0x1f, 6],
137
- [0x5c, 7],
138
- [0xfb, 8],
124
+ [0xfa, 8],
125
+ [0x16, 6],
126
+ [0x17, 6],
127
+ [0x18, 6],
128
+ [0x0, 5],
129
+ [0x1, 5],
130
+ [0x2, 5],
131
+ [0x19, 6],
132
+ [0x1a, 6],
133
+ [0x1b, 6],
134
+ [0x1c, 6],
135
+ [0x1d, 6],
136
+ [0x1e, 6],
137
+ [0x1f, 6],
138
+ [0x5c, 7],
139
+ [0xfb, 8],
139
140
  [0x7ffc, 15],
140
- [0x20, 6],
141
+ [0x20, 6],
141
142
  [0xffb, 12],
142
143
  [0x3fc, 10],
143
144
  [0x1ffa, 13],
144
- [0x21, 6],
145
- [0x5d, 7],
146
- [0x5e, 7],
147
- [0x5f, 7],
148
- [0x60, 7],
149
- [0x61, 7],
150
- [0x62, 7],
151
- [0x63, 7],
152
- [0x64, 7],
153
- [0x65, 7],
154
- [0x66, 7],
155
- [0x67, 7],
156
- [0x68, 7],
157
- [0x69, 7],
158
- [0x6a, 7],
159
- [0x6b, 7],
160
- [0x6c, 7],
161
- [0x6d, 7],
162
- [0x6e, 7],
163
- [0x6f, 7],
164
- [0x70, 7],
165
- [0x71, 7],
166
- [0x72, 7],
167
- [0xfc, 8],
168
- [0x73, 7],
169
- [0xfd, 8],
145
+ [0x21, 6],
146
+ [0x5d, 7],
147
+ [0x5e, 7],
148
+ [0x5f, 7],
149
+ [0x60, 7],
150
+ [0x61, 7],
151
+ [0x62, 7],
152
+ [0x63, 7],
153
+ [0x64, 7],
154
+ [0x65, 7],
155
+ [0x66, 7],
156
+ [0x67, 7],
157
+ [0x68, 7],
158
+ [0x69, 7],
159
+ [0x6a, 7],
160
+ [0x6b, 7],
161
+ [0x6c, 7],
162
+ [0x6d, 7],
163
+ [0x6e, 7],
164
+ [0x6f, 7],
165
+ [0x70, 7],
166
+ [0x71, 7],
167
+ [0x72, 7],
168
+ [0xfc, 8],
169
+ [0x73, 7],
170
+ [0xfd, 8],
170
171
  [0x1ffb, 13],
171
172
  [0x7fff0, 19],
172
173
  [0x1ffc, 13],
173
174
  [0x3ffc, 14],
174
- [0x22, 6],
175
+ [0x22, 6],
175
176
  [0x7ffd, 15],
176
- [0x3, 5],
177
- [0x23, 6],
178
- [0x4, 5],
179
- [0x24, 6],
180
- [0x5, 5],
181
- [0x25, 6],
182
- [0x26, 6],
183
- [0x27, 6],
184
- [0x6, 5],
185
- [0x74, 7],
186
- [0x75, 7],
187
- [0x28, 6],
188
- [0x29, 6],
189
- [0x2a, 6],
190
- [0x7, 5],
191
- [0x2b, 6],
192
- [0x76, 7],
193
- [0x2c, 6],
194
- [0x8, 5],
195
- [0x9, 5],
196
- [0x2d, 6],
197
- [0x77, 7],
198
- [0x78, 7],
199
- [0x79, 7],
200
- [0x7a, 7],
201
- [0x7b, 7],
177
+ [0x3, 5],
178
+ [0x23, 6],
179
+ [0x4, 5],
180
+ [0x24, 6],
181
+ [0x5, 5],
182
+ [0x25, 6],
183
+ [0x26, 6],
184
+ [0x27, 6],
185
+ [0x6, 5],
186
+ [0x74, 7],
187
+ [0x75, 7],
188
+ [0x28, 6],
189
+ [0x29, 6],
190
+ [0x2a, 6],
191
+ [0x7, 5],
192
+ [0x2b, 6],
193
+ [0x76, 7],
194
+ [0x2c, 6],
195
+ [0x8, 5],
196
+ [0x9, 5],
197
+ [0x2d, 6],
198
+ [0x77, 7],
199
+ [0x78, 7],
200
+ [0x79, 7],
201
+ [0x7a, 7],
202
+ [0x7b, 7],
202
203
  [0x7ffe, 15],
203
204
  [0x7fc, 11],
204
205
  [0x3ffd, 14],
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  # Copyrigh, 2013, by Ilya Grigorik.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -20,6 +22,6 @@
20
22
 
21
23
  module Protocol
22
24
  module HPACK
23
- VERSION = "1.4.1"
25
+ VERSION = "1.4.2"
24
26
  end
25
27
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  namespace :huffman do
3
4
  desc 'Generate the huffman state table'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require_relative '../lib/http/hpack/huffman'
3
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-hpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
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-06-21 00:00:00.000000000 Z
11
+ date: 2020-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: covered
@@ -93,7 +93,8 @@ files:
93
93
  - tasks/huffman.rake
94
94
  - tasks/huffman.rb
95
95
  homepage: https://github.com/socketry/http-hpack
96
- licenses: []
96
+ licenses:
97
+ - MIT
97
98
  metadata: {}
98
99
  post_install_message:
99
100
  rdoc_options: []
@@ -110,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
111
  - !ruby/object:Gem::Version
111
112
  version: '0'
112
113
  requirements: []
113
- rubygems_version: 3.0.2
114
+ rubygems_version: 3.1.2
114
115
  signing_key:
115
116
  specification_version: 4
116
117
  summary: A compresssor and decompressor for HTTP 2.0 HPACK.