protocol-hpack 1.4.2 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/protocol/hpack/compressor.rb +13 -25
- data/lib/protocol/hpack/context.rb +70 -48
- data/lib/protocol/hpack/decompressor.rb +69 -32
- data/lib/protocol/hpack/error.rb +2 -20
- data/lib/protocol/hpack/huffman/machine.rb +2 -20
- data/lib/protocol/hpack/huffman.rb +13 -24
- data/lib/protocol/hpack/version.rb +3 -20
- data/lib/protocol/hpack.rb +2 -19
- data/license.md +37 -0
- data/readme.md +34 -0
- data/tasks/huffman.rb +17 -25
- data.tar.gz.sig +0 -0
- metadata +61 -78
- metadata.gz.sig +1 -0
- data/.editorconfig +0 -6
- data/.gitignore +0 -12
- data/.gitmodules +0 -3
- data/.rspec +0 -3
- data/.travis.yml +0 -20
- data/Gemfile +0 -6
- data/README.md +0 -84
- data/Rakefile +0 -10
- data/http-hpack.gemspec +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d664c70ae90134d28bf5491fe5f46612ce17292d8ebdc06daba9e423459501e
|
4
|
+
data.tar.gz: 0ede73ffcfb63a755022f3212309ce6ce4a74dcebd819f0287f8cf610a17fbee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a194f5bbdfdbb5552f0ca6216b9cbb314bb5590a10316d51f99578961ebd3247bfa3aea6f3f8430f0e2f34ec89e9a18574c7080988f5cfde571b58ed8d6b143e
|
7
|
+
data.tar.gz: e11f0747b74859d27a2834350e46c49ea573e71f772687b387d6b4e4d1fd6b3033bc2c99537961fe2c59944e0acb2e0aeb78c0d7a9dbeb681cb04391d7e0ebb2
|
checksums.yaml.gz.sig
ADDED
Binary file
|
@@ -1,25 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2013-2015, by Ilya Grigorik.
|
5
|
+
# Copyright, 2014-2015, by Kaoru Maeda.
|
6
|
+
# Copyright, 2015, by Tamir Duberstein.
|
7
|
+
# Copyright, 2016, by George Ulmer.
|
8
|
+
# Copyright, 2018, by Tiago Cardoso.
|
9
|
+
# Copyright, 2018, by Byron Formwalt.
|
10
|
+
# Copyright, 2018-2024, by Samuel Williams.
|
11
|
+
# Copyright, 2018, by Kenichi Nakamura.
|
12
|
+
# Copyright, 2019, by Jingyi Chen.
|
13
|
+
# Copyright, 2020, by Justin Mazzocchi.
|
14
|
+
# Copyright, 2024, by Nathan Froyd.
|
23
15
|
|
24
16
|
require_relative 'context'
|
25
17
|
require_relative 'huffman'
|
@@ -63,10 +55,6 @@ module Protocol
|
|
63
55
|
attr :context
|
64
56
|
attr :offset
|
65
57
|
|
66
|
-
def write_byte(byte)
|
67
|
-
@buffer << byte.chr
|
68
|
-
end
|
69
|
-
|
70
58
|
def write_bytes(bytes)
|
71
59
|
@buffer << bytes
|
72
60
|
end
|
@@ -131,7 +119,7 @@ module Protocol
|
|
131
119
|
# @return [String] binary string
|
132
120
|
def write_string(string, huffman = self.huffman)
|
133
121
|
if huffman != :never
|
134
|
-
encoded = Huffman.
|
122
|
+
encoded = Huffman.encode(string)
|
135
123
|
|
136
124
|
if huffman == :shorter and encoded.bytesize >= string.bytesize
|
137
125
|
encoded = nil
|
@@ -1,25 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# of this software and associated documentation files (the "Software"), to deal
|
8
|
-
# in the Software without restriction, including without limitation the rights
|
9
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
# copies of the Software, and to permit persons to whom the Software is
|
11
|
-
# furnished to do so, subject to the following conditions:
|
12
|
-
#
|
13
|
-
# The above copyright notice and this permission notice shall be included in
|
14
|
-
# all copies or substantial portions of the Software.
|
15
|
-
#
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2018-2024, by Samuel Williams.
|
5
|
+
# Copyright, 2024, by Maruth Goyal.
|
6
|
+
# Copyright, 2024, by Nathan Froyd.
|
23
7
|
|
24
8
|
require_relative 'huffman'
|
25
9
|
|
@@ -30,12 +14,17 @@ module Protocol
|
|
30
14
|
# - http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-10
|
31
15
|
module HPACK
|
32
16
|
# Header representation as defined by the spec.
|
17
|
+
NO_INDEX_TYPE = {prefix: 4, pattern: 0x00}.freeze
|
18
|
+
NEVER_INDEXED_TYPE = {prefix: 4, pattern: 0x10}.freeze
|
19
|
+
CHANGE_TABLE_SIZE_TYPE = {prefix: 5, pattern: 0x20}.freeze
|
20
|
+
INCREMENTAL_TYPE = {prefix: 6, pattern: 0x40}.freeze
|
21
|
+
INDEXED_TYPE = {prefix: 7, pattern: 0x80}.freeze
|
33
22
|
HEADER_REPRESENTATION = {
|
34
|
-
indexed:
|
35
|
-
incremental:
|
36
|
-
no_index:
|
37
|
-
never_indexed:
|
38
|
-
change_table_size:
|
23
|
+
indexed: INDEXED_TYPE,
|
24
|
+
incremental: INCREMENTAL_TYPE,
|
25
|
+
no_index: NO_INDEX_TYPE,
|
26
|
+
never_indexed: NEVER_INDEXED_TYPE,
|
27
|
+
change_table_size: CHANGE_TABLE_SIZE_TYPE
|
39
28
|
}
|
40
29
|
|
41
30
|
# To decompress header blocks, a decoder only needs to maintain a
|
@@ -107,7 +96,20 @@ module Protocol
|
|
107
96
|
["via", ""],
|
108
97
|
["www-authenticate", ""],
|
109
98
|
].each(&:freeze).freeze
|
110
|
-
|
99
|
+
|
100
|
+
STATIC_EXACT_LOOKUP = {}
|
101
|
+
STATIC_NAME_LOOKUP = {}
|
102
|
+
|
103
|
+
STATIC_TABLE.each_with_index do |(name, value), i|
|
104
|
+
exact_header_values = (STATIC_EXACT_LOOKUP[name] ||= [])
|
105
|
+
exact_header_values << [value, i]
|
106
|
+
STATIC_NAME_LOOKUP[name] = i if STATIC_NAME_LOOKUP[name].nil?
|
107
|
+
end
|
108
|
+
|
109
|
+
STATIC_EXACT_LOOKUP.each {|k, v| v.freeze}
|
110
|
+
STATIC_EXACT_LOOKUP.freeze
|
111
|
+
STATIC_NAME_LOOKUP.freeze
|
112
|
+
|
111
113
|
# Initializes compression context with appropriate client/server defaults and maximum size of the dynamic table.
|
112
114
|
#
|
113
115
|
# @param table [Array] Table of header key-value pairs.
|
@@ -246,29 +248,42 @@ module Protocol
|
|
246
248
|
# :static Use static table only.
|
247
249
|
# :all Use all of them.
|
248
250
|
#
|
249
|
-
# @param
|
251
|
+
# @param name [String]
|
252
|
+
# @param value [String]
|
250
253
|
# @return [Hash] command
|
251
|
-
def add_command(
|
254
|
+
def add_command(name, value)
|
252
255
|
exact = nil
|
253
256
|
name_only = nil
|
254
257
|
|
255
|
-
if
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
258
|
+
if @index == :all || @index == :static
|
259
|
+
if (values_and_indices = STATIC_EXACT_LOOKUP[name])
|
260
|
+
values_and_indices.each do |known_value, index|
|
261
|
+
if value == known_value
|
262
|
+
exact = index
|
263
|
+
break
|
264
|
+
end
|
262
265
|
end
|
266
|
+
|
267
|
+
needs_name_lookup = exact.nil?
|
268
|
+
else
|
269
|
+
needs_name_lookup = true
|
270
|
+
end
|
271
|
+
|
272
|
+
if needs_name_lookup && (static_value = STATIC_NAME_LOOKUP[name])
|
273
|
+
name_only = static_value
|
263
274
|
end
|
264
275
|
end
|
265
|
-
|
276
|
+
|
277
|
+
if @index == :all && !exact
|
266
278
|
@table.each_index do |i|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
279
|
+
entry = @table[i]
|
280
|
+
if entry.first == name
|
281
|
+
if entry.last == value
|
282
|
+
exact ||= i + STATIC_TABLE.size
|
283
|
+
break
|
284
|
+
else
|
285
|
+
name_only ||= i + STATIC_TABLE.size
|
286
|
+
end
|
272
287
|
end
|
273
288
|
end
|
274
289
|
end
|
@@ -276,9 +291,9 @@ module Protocol
|
|
276
291
|
if exact
|
277
292
|
{name: exact, type: :indexed}
|
278
293
|
elsif name_only
|
279
|
-
{name: name_only, value:
|
294
|
+
{name: name_only, value: value, type: :incremental}
|
280
295
|
else
|
281
|
-
{name:
|
296
|
+
{name: name, value: value, type: :incremental}
|
282
297
|
end
|
283
298
|
end
|
284
299
|
|
@@ -298,8 +313,8 @@ module Protocol
|
|
298
313
|
|
299
314
|
# Returns current table size in octets
|
300
315
|
# @return [Integer]
|
301
|
-
def
|
302
|
-
@table.
|
316
|
+
def compute_current_table_size
|
317
|
+
@table.sum { |k, v| k.bytesize + v.bytesize + 32 }
|
303
318
|
end
|
304
319
|
|
305
320
|
private
|
@@ -314,6 +329,11 @@ module Protocol
|
|
314
329
|
command.freeze
|
315
330
|
|
316
331
|
@table.unshift(command)
|
332
|
+
@current_table_size += entry_size(command)
|
333
|
+
end
|
334
|
+
|
335
|
+
def entry_size(e)
|
336
|
+
e[0].bytesize + e[1].bytesize + 32
|
317
337
|
end
|
318
338
|
|
319
339
|
# To keep the dynamic table size lower than or equal to @table_size,
|
@@ -322,14 +342,16 @@ module Protocol
|
|
322
342
|
# @param command [Hash]
|
323
343
|
# @return [Boolean] whether +command+ fits in the dynamic table.
|
324
344
|
def size_check(command)
|
325
|
-
|
345
|
+
|
346
|
+
@current_table_size ||= compute_current_table_size
|
347
|
+
|
326
348
|
cmdsize = command.nil? ? 0 : command[0].bytesize + command[1].bytesize + 32
|
327
349
|
|
328
|
-
while
|
350
|
+
while @current_table_size + cmdsize > @table_size
|
329
351
|
break if @table.empty?
|
330
352
|
|
331
353
|
e = @table.pop
|
332
|
-
|
354
|
+
@current_table_size -= e[0].bytesize + e[1].bytesize + 32
|
333
355
|
end
|
334
356
|
|
335
357
|
cmdsize <= @table_size
|
@@ -1,25 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# of this software and associated documentation files (the "Software"), to deal
|
8
|
-
# in the Software without restriction, including without limitation the rights
|
9
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
# copies of the Software, and to permit persons to whom the Software is
|
11
|
-
# furnished to do so, subject to the following conditions:
|
12
|
-
#
|
13
|
-
# The above copyright notice and this permission notice shall be included in
|
14
|
-
# all copies or substantial portions of the Software.
|
15
|
-
#
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2018-2024, by Samuel Williams.
|
5
|
+
# Copyright, 2024, by Maruth Goyal.
|
6
|
+
# Copyright, 2024, by Nathan Froyd.
|
23
7
|
|
24
8
|
require_relative 'context'
|
25
9
|
require_relative 'huffman'
|
@@ -30,6 +14,9 @@ module Protocol
|
|
30
14
|
# context of the opposing peer. Decompressor must be initialized with
|
31
15
|
# appropriate starting context based on local role: client or server.
|
32
16
|
class Decompressor
|
17
|
+
|
18
|
+
MASK_SHIFT_4 = (~0x0 >> 4) << 4
|
19
|
+
|
33
20
|
def initialize(buffer, context = Context.new, table_size_limit: nil)
|
34
21
|
@buffer = buffer
|
35
22
|
@context = context
|
@@ -103,7 +90,7 @@ module Protocol
|
|
103
90
|
|
104
91
|
raise CompressionError, "Invalid string length, got #{string.bytesize}, expecting #{length}!" unless string.bytesize == length
|
105
92
|
|
106
|
-
string = Huffman.
|
93
|
+
string = Huffman.decode(string) if huffman
|
107
94
|
|
108
95
|
return string.force_encoding(Encoding::UTF_8)
|
109
96
|
end
|
@@ -116,30 +103,80 @@ module Protocol
|
|
116
103
|
pattern = peek_byte
|
117
104
|
|
118
105
|
header = {}
|
119
|
-
header[:type], type = HEADER_REPRESENTATION.find do |_t, desc|
|
120
|
-
mask = (pattern >> desc[:prefix]) << desc[:prefix]
|
121
|
-
mask == desc[:pattern]
|
122
|
-
end
|
123
106
|
|
124
|
-
|
107
|
+
type = nil
|
108
|
+
|
109
|
+
# (pattern & MASK_SHIFT_4) clears bottom 4 bits,
|
110
|
+
# equivalent to (pattern >> 4) << 4. For the
|
111
|
+
# no-index and never-indexed type we only need to clear
|
112
|
+
# the bottom 4 bits (as specified by NO_INDEX_TYPE[:prefix])
|
113
|
+
# so we directly check against NO_INDEX_TYPE[:pattern].
|
114
|
+
# But for change-table-size, incremental, and indexed
|
115
|
+
# we must clear 5,6, and 7 bits respectively.
|
116
|
+
# Consider indexed where we need to clear 7 bits.
|
117
|
+
# Since (pattern & MASK_SHIFT_4)'s bottom 4 bits are cleared
|
118
|
+
# you can visualize it as
|
119
|
+
#
|
120
|
+
# INDEXED_TYPE[:pattern] = <some bits> 0 0 0 0 0 0 0
|
121
|
+
# ^^^^^^^^^^^^^^^^ 7 bits
|
122
|
+
# (pattern & MASK_SHIFT_4) = <pattern bits> b1 b2 b3 0 0 0 0
|
123
|
+
#
|
124
|
+
# Computing equality after masking bottom 7 bits (i.e., set b1 = b2 = b3 = 0)
|
125
|
+
# is the same as checking equality against
|
126
|
+
# <some bits> x1 x2 x3 0 0 0 0
|
127
|
+
# For *every* possible value of x1, x2, x3 (that is, 2^3 = 8 values).
|
128
|
+
# INDEXED_TYPE[:pattern] = 0x80, so we check against 0x80, 0x90 = 0x80 + (0b001 << 4)
|
129
|
+
# 0xa0 = 0x80 + (0b001 << 5), ..., 0xf0 = 0x80 + (0b111 << 4).
|
130
|
+
# While not the most readable, we have written out everything as constant literals
|
131
|
+
# so Ruby can optimize this case-when to a hash lookup.
|
132
|
+
#
|
133
|
+
# There's no else case as this list is exhaustive.
|
134
|
+
# (0..255).map { |x| (x & -16).to_s(16) }.uniq will show this
|
135
|
+
|
136
|
+
case (pattern & MASK_SHIFT_4)
|
137
|
+
when 0x00
|
138
|
+
header[:type] = :no_index
|
139
|
+
type = NO_INDEX_TYPE
|
140
|
+
when 0x10
|
141
|
+
header[:type] = :never_indexed
|
142
|
+
type = NEVER_INDEXED_TYPE
|
143
|
+
# checking if (pattern >> 5) << 5 == 0x20
|
144
|
+
# Since we cleared bottom 4 bits, the 5th
|
145
|
+
# bit can be either 0 or 1, so check both
|
146
|
+
# cases.
|
147
|
+
when 0x20, 0x30
|
148
|
+
header[:type] = :change_table_size
|
149
|
+
type = CHANGE_TABLE_SIZE_TYPE
|
150
|
+
# checking if (pattern >> 6) << 6 == 0x40
|
151
|
+
# Same logic as above, but now over the 4
|
152
|
+
# possible combinations of 2 bits (5th, 6th)
|
153
|
+
when 0x40, 0x50, 0x60, 0x70
|
154
|
+
header[:type] = :incremental
|
155
|
+
type = INCREMENTAL_TYPE
|
156
|
+
# checking if (pattern >> 7) << 7 == 0x80
|
157
|
+
when 0x80, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0
|
158
|
+
header[:type] = :indexed
|
159
|
+
type = INDEXED_TYPE
|
160
|
+
end
|
125
161
|
|
126
|
-
|
162
|
+
header_name = read_integer(type[:prefix])
|
127
163
|
|
128
164
|
case header[:type]
|
129
165
|
when :indexed
|
130
|
-
raise CompressionError if
|
131
|
-
header[:name]
|
166
|
+
raise CompressionError if header_name.zero?
|
167
|
+
header[:name] = header_name - 1
|
132
168
|
when :change_table_size
|
133
|
-
header[:
|
169
|
+
header[:name] = header_name
|
170
|
+
header[:value] = header_name
|
134
171
|
|
135
172
|
if @table_size_limit and header[:value] > @table_size_limit
|
136
173
|
raise CompressionError, "Table size #{header[:value]} exceeds limit #{@table_size_limit}!"
|
137
174
|
end
|
138
175
|
else
|
139
|
-
if
|
176
|
+
if header_name.zero?
|
140
177
|
header[:name] = read_string
|
141
178
|
else
|
142
|
-
header[:name]
|
179
|
+
header[:name] = header_name - 1
|
143
180
|
end
|
144
181
|
|
145
182
|
header[:value] = read_string
|
data/lib/protocol/hpack/error.rb
CHANGED
@@ -1,25 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
# of this software and associated documentation files (the "Software"), to deal
|
8
|
-
# in the Software without restriction, including without limitation the rights
|
9
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
# copies of the Software, and to permit persons to whom the Software is
|
11
|
-
# furnished to do so, subject to the following conditions:
|
12
|
-
#
|
13
|
-
# The above copyright notice and this permission notice shall be included in
|
14
|
-
# all copies or substantial portions of the Software.
|
15
|
-
#
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2019-2024, by Samuel Williams.
|
23
5
|
|
24
6
|
module Protocol
|
25
7
|
module HPACK
|
@@ -1,25 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
# of this software and associated documentation files (the "Software"), to deal
|
8
|
-
# in the Software without restriction, including without limitation the rights
|
9
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
# copies of the Software, and to permit persons to whom the Software is
|
11
|
-
# furnished to do so, subject to the following conditions:
|
12
|
-
#
|
13
|
-
# The above copyright notice and this permission notice shall be included in
|
14
|
-
# all copies or substantial portions of the Software.
|
15
|
-
#
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2018-2024, by Samuel Williams.
|
23
5
|
|
24
6
|
# Machine generated Huffman decoder state machine.
|
25
7
|
# DO NOT EDIT THIS FILE.
|
@@ -1,25 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# copies of the Software, and to permit persons to whom the Software is
|
11
|
-
# furnished to do so, subject to the following conditions:
|
12
|
-
#
|
13
|
-
# The above copyright notice and this permission notice shall be included in
|
14
|
-
# all copies or substantial portions of the Software.
|
15
|
-
#
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2014-2015, by Kaoru Maeda.
|
5
|
+
# Copyright, 2015, by Ilya Grigorik.
|
6
|
+
# Copyright, 2015, by Tamir Duberstein.
|
7
|
+
# Copyright, 2018-2024, by Samuel Williams.
|
8
|
+
# Copyright, 2022, by Daniel Morrison.
|
9
|
+
# Copyright, 2024, by Nathan Froyd.
|
23
10
|
|
24
11
|
require_relative 'huffman/machine'
|
25
12
|
require_relative 'error'
|
@@ -36,7 +23,7 @@ module Protocol
|
|
36
23
|
#
|
37
24
|
# @param str [String]
|
38
25
|
# @return [String] binary string
|
39
|
-
def encode(str)
|
26
|
+
def self.encode(str)
|
40
27
|
bitstring = str.each_byte.map {|chr| ENCODE_TABLE[chr]}.join
|
41
28
|
bitstring << '1' * ((8 - bitstring.size) % 8)
|
42
29
|
[bitstring].pack('B*')
|
@@ -47,14 +34,15 @@ module Protocol
|
|
47
34
|
# @param buf [Buffer]
|
48
35
|
# @return [String] binary string
|
49
36
|
# @raise [CompressionError] when Huffman coded string is malformed
|
50
|
-
def decode(buffer)
|
37
|
+
def self.decode(buffer)
|
51
38
|
emit = String.new.b
|
52
39
|
state = 0 # start state
|
53
40
|
|
54
41
|
mask = (1 << BITS_AT_ONCE) - 1
|
55
42
|
buffer.each_byte do |c|
|
56
|
-
|
57
|
-
|
43
|
+
shift = BITS_AT_ONCE
|
44
|
+
while shift >= 0
|
45
|
+
branch = (c >> shift) & mask
|
58
46
|
|
59
47
|
# MACHINE[state] = [final, [transitions]]
|
60
48
|
# [final] unfinished bits so far are prefix of the EOS code.
|
@@ -66,6 +54,7 @@ module Protocol
|
|
66
54
|
raise CompressionError, 'Huffman decode error (EOS found)' if value == EOS
|
67
55
|
|
68
56
|
emit << value.chr if value
|
57
|
+
shift -= BITS_AT_ONCE
|
69
58
|
end
|
70
59
|
end
|
71
60
|
# Check whether partial input is correctly filled
|
@@ -1,27 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2018-2024, by Samuel Williams.
|
22
5
|
|
23
6
|
module Protocol
|
24
7
|
module HPACK
|
25
|
-
VERSION = "1.
|
8
|
+
VERSION = "1.5.0"
|
26
9
|
end
|
27
10
|
end
|
data/lib/protocol/hpack.rb
CHANGED
@@ -1,24 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2018-2024, by Samuel Williams.
|
22
5
|
|
23
6
|
require_relative "hpack/version"
|
24
7
|
|
data/license.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# MIT License
|
2
|
+
|
3
|
+
Copyright, 2013-2016, by Ilya Grigorik.
|
4
|
+
Copyright, 2014-2015, by Kaoru Maeda.
|
5
|
+
Copyright, 2015, by Tamir Duberstein.
|
6
|
+
Copyright, 2016, by Kien Nguyen Trung.
|
7
|
+
Copyright, 2016, by George Ulmer.
|
8
|
+
Copyright, 2018, by Tiago Cardoso.
|
9
|
+
Copyright, 2018, by Byron Formwalt.
|
10
|
+
Copyright, 2018-2024, by Samuel Williams.
|
11
|
+
Copyright, 2018, by Kenichi Nakamura.
|
12
|
+
Copyright, 2019, by Jingyi Chen.
|
13
|
+
Copyright, 2019, by Cyril Roelandt.
|
14
|
+
Copyright, 2020, by Olle Jonsson.
|
15
|
+
Copyright, 2020, by Justin Mazzocchi.
|
16
|
+
Copyright, 2022, by Daniel Morrison.
|
17
|
+
Copyright, 2022, by Felix Yan.
|
18
|
+
Copyright, 2024, by Maruth Goyal.
|
19
|
+
Copyright, 2024, by Nathan Froyd.
|
20
|
+
|
21
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
22
|
+
of this software and associated documentation files (the "Software"), to deal
|
23
|
+
in the Software without restriction, including without limitation the rights
|
24
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
25
|
+
copies of the Software, and to permit persons to whom the Software is
|
26
|
+
furnished to do so, subject to the following conditions:
|
27
|
+
|
28
|
+
The above copyright notice and this permission notice shall be included in all
|
29
|
+
copies or substantial portions of the Software.
|
30
|
+
|
31
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
32
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
33
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
34
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
35
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
36
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
37
|
+
SOFTWARE.
|
data/readme.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Protocol::HPACK
|
2
|
+
|
3
|
+
Provides a compressor and decompressor for HTTP 2.0 headers, HPACK, as defined by [RFC7541](https://tools.ietf.org/html/rfc7541).
|
4
|
+
|
5
|
+
[![Development Status](https://github.com/socketry/protocol-hpack/workflows/Test/badge.svg)](https://github.com/socketry/protocol-hpack/actions?workflow=Test)
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
Please see the [project documentation](https://socketry.github.io/protocol-hpack/) for more details.
|
10
|
+
|
11
|
+
- [Getting Started](https://socketry.github.io/protocol-hpack/guides/getting-started/index) - This guide explains how to use the `protocol-hpack` gem to compress and decompress HTTP/2 headers using HPACK.
|
12
|
+
|
13
|
+
## See Also
|
14
|
+
|
15
|
+
- [protocol-http2](https://github.com/socketry/protocol-http2) - Provides an HTTP/2 client and server implementation.
|
16
|
+
- [async-http](https://github.com/socketry/async-http) - Provides a complete HTTP client and server implementation on top of Async.
|
17
|
+
|
18
|
+
## Contributing
|
19
|
+
|
20
|
+
We welcome contributions to this project.
|
21
|
+
|
22
|
+
1. Fork it.
|
23
|
+
2. Create your feature branch (`git checkout -b my-new-feature`).
|
24
|
+
3. Commit your changes (`git commit -am 'Add some feature'`).
|
25
|
+
4. Push to the branch (`git push origin my-new-feature`).
|
26
|
+
5. Create new Pull Request.
|
27
|
+
|
28
|
+
### Developer Certificate of Origin
|
29
|
+
|
30
|
+
In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
|
31
|
+
|
32
|
+
### Community Guidelines
|
33
|
+
|
34
|
+
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
|
data/tasks/huffman.rb
CHANGED
@@ -1,11 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2014, by Kaoru Maeda.
|
5
|
+
# Copyright, 2015, by Tamir Duberstein.
|
6
|
+
# Copyright, 2015, by Ilya Grigorik.
|
7
|
+
# Copyright, 2016, by George Ulmer.
|
8
|
+
# Copyright, 2018-2024, by Samuel Williams.
|
9
|
+
# Copyright, 2024, by Nathan Froyd.
|
10
|
+
|
11
|
+
require_relative '../lib/protocol/hpack/huffman'
|
4
12
|
|
5
13
|
require 'set'
|
6
14
|
|
7
15
|
module Huffman
|
8
|
-
BITS_AT_ONCE =
|
16
|
+
BITS_AT_ONCE = Protocol::HPACK::Huffman::BITS_AT_ONCE
|
9
17
|
EOS = 256
|
10
18
|
|
11
19
|
class Node
|
@@ -42,7 +50,7 @@ module Huffman
|
|
42
50
|
|
43
51
|
def self.generate_tree
|
44
52
|
@root = new(0)
|
45
|
-
|
53
|
+
Protocol::HPACK::Huffman::CODES.each_with_index do |c, chr|
|
46
54
|
code, len = c
|
47
55
|
@root.add(code, len, chr)
|
48
56
|
end
|
@@ -64,7 +72,7 @@ module Huffman
|
|
64
72
|
|
65
73
|
(1 << BITS_AT_ONCE).times do |input|
|
66
74
|
n = node
|
67
|
-
emit = ''
|
75
|
+
emit = +''
|
68
76
|
(BITS_AT_ONCE - 1).downto(0) do |i|
|
69
77
|
bit = (input & (1 << i)).zero? ? 0 : 1
|
70
78
|
n = n.next[bit]
|
@@ -100,28 +108,12 @@ module Huffman
|
|
100
108
|
id += 1
|
101
109
|
end
|
102
110
|
|
103
|
-
File.open(File.expand_path('../lib/
|
111
|
+
File.open(File.expand_path('../lib/protocol/hpack/huffman/machine.rb', File.dirname(__FILE__)), 'w') do |f|
|
104
112
|
f.print <<HEADER
|
105
|
-
#
|
106
|
-
|
107
|
-
#
|
108
|
-
#
|
109
|
-
# of this software and associated documentation files (the "Software"), to deal
|
110
|
-
# in the Software without restriction, including without limitation the rights
|
111
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
112
|
-
# copies of the Software, and to permit persons to whom the Software is
|
113
|
-
# furnished to do so, subject to the following conditions:
|
114
|
-
#
|
115
|
-
# The above copyright notice and this permission notice shall be included in
|
116
|
-
# all copies or substantial portions of the Software.
|
117
|
-
#
|
118
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
119
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
120
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
121
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
122
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
123
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
124
|
-
# THE SOFTWARE.
|
113
|
+
# frozen_string_literal: true
|
114
|
+
|
115
|
+
# Released under the MIT License.
|
116
|
+
# Copyright, 2018-2024, by Samuel Williams.
|
125
117
|
|
126
118
|
# Machine generated Huffman decoder state machine.
|
127
119
|
# DO NOT EDIT THIS FILE.
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
CHANGED
@@ -1,87 +1,66 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protocol-hpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
-
|
8
|
+
- Ilya Grigorik
|
9
|
+
- Tamir Duberstein
|
10
|
+
- Nathan Froyd
|
11
|
+
- Kaoru Maeda
|
12
|
+
- Tiago Cardoso
|
13
|
+
- Byron Formwalt
|
14
|
+
- Cyril Roelandt
|
15
|
+
- Daniel Morrison
|
16
|
+
- Felix Yan
|
17
|
+
- George Ulmer
|
18
|
+
- Jingyi Chen
|
19
|
+
- Justin Mazzocchi
|
20
|
+
- Kenichi Nakamura
|
21
|
+
- Kien Nguyen Trung
|
22
|
+
- Maruth Goyal
|
23
|
+
- Olle Jonsson
|
24
|
+
autorequire:
|
9
25
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '10.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '10.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '3.0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '3.0'
|
69
|
-
description:
|
26
|
+
cert_chain:
|
27
|
+
- |
|
28
|
+
-----BEGIN CERTIFICATE-----
|
29
|
+
MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
|
30
|
+
ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
|
31
|
+
CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
|
32
|
+
MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
|
33
|
+
MBsGCgmSJomT8ixkARkWDW9yaW9udHJhbnNmZXIxEjAQBgoJkiaJk/IsZAEZFgJj
|
34
|
+
bzESMBAGCgmSJomT8ixkARkWAm56MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIB
|
35
|
+
igKCAYEAomvSopQXQ24+9DBB6I6jxRI2auu3VVb4nOjmmHq7XWM4u3HL+pni63X2
|
36
|
+
9qZdoq9xt7H+RPbwL28LDpDNflYQXoOhoVhQ37Pjn9YDjl8/4/9xa9+NUpl9XDIW
|
37
|
+
sGkaOY0eqsQm1pEWkHJr3zn/fxoKPZPfaJOglovdxf7dgsHz67Xgd/ka+Wo1YqoE
|
38
|
+
e5AUKRwUuvaUaumAKgPH+4E4oiLXI4T1Ff5Q7xxv6yXvHuYtlMHhYfgNn8iiW8WN
|
39
|
+
XibYXPNP7NtieSQqwR/xM6IRSoyXKuS+ZNGDPUUGk8RoiV/xvVN4LrVm9upSc0ss
|
40
|
+
RZ6qwOQmXCo/lLcDUxJAgG95cPw//sI00tZan75VgsGzSWAOdjQpFM0l4dxvKwHn
|
41
|
+
tUeT3ZsAgt0JnGqNm2Bkz81kG4A2hSyFZTFA8vZGhp+hz+8Q573tAR89y9YJBdYM
|
42
|
+
zp0FM4zwMNEUwgfRzv1tEVVUEXmoFCyhzonUUw4nE4CFu/sE3ffhjKcXcY//qiSW
|
43
|
+
xm4erY3XAgMBAAGjgZowgZcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
|
44
|
+
BBYEFO9t7XWuFf2SKLmuijgqR4sGDlRsMC4GA1UdEQQnMCWBI3NhbXVlbC53aWxs
|
45
|
+
aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWBI3NhbXVlbC53aWxs
|
46
|
+
aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEBCwUAA4IBgQB5sxkE
|
47
|
+
cBsSYwK6fYpM+hA5B5yZY2+L0Z+27jF1pWGgbhPH8/FjjBLVn+VFok3CDpRqwXCl
|
48
|
+
xCO40JEkKdznNy2avOMra6PFiQyOE74kCtv7P+Fdc+FhgqI5lMon6tt9rNeXmnW/
|
49
|
+
c1NaMRdxy999hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
|
50
|
+
8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
|
51
|
+
JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
|
52
|
+
eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
|
53
|
+
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
54
|
+
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
55
|
+
-----END CERTIFICATE-----
|
56
|
+
date: 2024-07-28 00:00:00.000000000 Z
|
57
|
+
dependencies: []
|
58
|
+
description:
|
70
59
|
email:
|
71
|
-
- samuel.williams@oriontransfer.co.nz
|
72
60
|
executables: []
|
73
61
|
extensions: []
|
74
62
|
extra_rdoc_files: []
|
75
63
|
files:
|
76
|
-
- ".editorconfig"
|
77
|
-
- ".gitignore"
|
78
|
-
- ".gitmodules"
|
79
|
-
- ".rspec"
|
80
|
-
- ".travis.yml"
|
81
|
-
- Gemfile
|
82
|
-
- README.md
|
83
|
-
- Rakefile
|
84
|
-
- http-hpack.gemspec
|
85
64
|
- lib/protocol/hpack.rb
|
86
65
|
- lib/protocol/hpack/compressor.rb
|
87
66
|
- lib/protocol/hpack/context.rb
|
@@ -90,13 +69,17 @@ files:
|
|
90
69
|
- lib/protocol/hpack/huffman.rb
|
91
70
|
- lib/protocol/hpack/huffman/machine.rb
|
92
71
|
- lib/protocol/hpack/version.rb
|
72
|
+
- license.md
|
73
|
+
- readme.md
|
93
74
|
- tasks/huffman.rake
|
94
75
|
- tasks/huffman.rb
|
95
76
|
homepage: https://github.com/socketry/http-hpack
|
96
77
|
licenses:
|
97
78
|
- MIT
|
98
|
-
metadata:
|
99
|
-
|
79
|
+
metadata:
|
80
|
+
documentation_uri: https://socketry.github.io/protocol-hpack/
|
81
|
+
source_code_uri: https://github.com/socketry/http-hpack.git
|
82
|
+
post_install_message:
|
100
83
|
rdoc_options: []
|
101
84
|
require_paths:
|
102
85
|
- lib
|
@@ -104,15 +87,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
104
87
|
requirements:
|
105
88
|
- - ">="
|
106
89
|
- !ruby/object:Gem::Version
|
107
|
-
version: '
|
90
|
+
version: '3.1'
|
108
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
92
|
requirements:
|
110
93
|
- - ">="
|
111
94
|
- !ruby/object:Gem::Version
|
112
95
|
version: '0'
|
113
96
|
requirements: []
|
114
|
-
rubygems_version: 3.
|
115
|
-
signing_key:
|
97
|
+
rubygems_version: 3.5.11
|
98
|
+
signing_key:
|
116
99
|
specification_version: 4
|
117
|
-
summary: A compresssor and decompressor for HTTP
|
100
|
+
summary: A compresssor and decompressor for HTTP/2's HPACK format.
|
118
101
|
test_files: []
|
metadata.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1�eQ��7�r�1�X2��n��<���YxT��Hh��@pMT�>�b��% ɕ5�
|
data/.editorconfig
DELETED
data/.gitignore
DELETED
data/.gitmodules
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
dist: xenial
|
3
|
-
cache: bundler
|
4
|
-
|
5
|
-
matrix:
|
6
|
-
include:
|
7
|
-
- rvm: 2.4
|
8
|
-
- rvm: 2.5
|
9
|
-
- rvm: 2.6
|
10
|
-
- rvm: 2.7
|
11
|
-
- rvm: 2.6
|
12
|
-
env: COVERAGE=PartialSummary,Coveralls
|
13
|
-
- rvm: truffleruby
|
14
|
-
- rvm: jruby-head
|
15
|
-
env: JRUBY_OPTS="--debug -X+O"
|
16
|
-
- rvm: ruby-head
|
17
|
-
allow_failures:
|
18
|
-
- rvm: truffleruby
|
19
|
-
- rvm: ruby-head
|
20
|
-
- rvm: jruby-head
|
data/Gemfile
DELETED
data/README.md
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
# Protocol::HPACK
|
2
|
-
|
3
|
-
Provides a compressor and decompressor for HTTP 2.0 headers, HPACK, as defined by [RFC7541](https://tools.ietf.org/html/rfc7541).
|
4
|
-
|
5
|
-
[![Build Status](https://secure.travis-ci.com/socketry/protocol-hpack.svg)](http://travis-ci.com/socketry/protocol-hpack)
|
6
|
-
[![Coverage Status](https://coveralls.io/repos/github/socketry/protocol-hpack/badge.svg?branch=master)](https://coveralls.io/github/socketry/protocol-hpack?branch=master)
|
7
|
-
|
8
|
-
## Installation
|
9
|
-
|
10
|
-
Add this line to your application's Gemfile:
|
11
|
-
|
12
|
-
```ruby
|
13
|
-
gem 'protocol-hpack'
|
14
|
-
```
|
15
|
-
|
16
|
-
And then execute:
|
17
|
-
|
18
|
-
$ bundle
|
19
|
-
|
20
|
-
Or install it yourself as:
|
21
|
-
|
22
|
-
$ gem install protocol-hpack
|
23
|
-
|
24
|
-
## Usage
|
25
|
-
|
26
|
-
### Compressing Headers
|
27
|
-
|
28
|
-
```ruby
|
29
|
-
require 'protocol/hpack'
|
30
|
-
|
31
|
-
buffer = String.new.b
|
32
|
-
compressor = Protocol::HPACK::Compressor.new(buffer)
|
33
|
-
|
34
|
-
compressor.encode([['content-length', '5']])
|
35
|
-
=> "\\\x015"
|
36
|
-
```
|
37
|
-
|
38
|
-
### Decompressing Headers
|
39
|
-
|
40
|
-
Reusing `buffer` from above:
|
41
|
-
|
42
|
-
```ruby
|
43
|
-
require 'protocol/hpack'
|
44
|
-
|
45
|
-
# Buffer from above...
|
46
|
-
buffer = "\\\x015"
|
47
|
-
decompressor = Protocol::HPACK::Decompressor.new(buffer)
|
48
|
-
|
49
|
-
decompressor.decode
|
50
|
-
=> [["content-length", "5"]]
|
51
|
-
```
|
52
|
-
|
53
|
-
## Contributing
|
54
|
-
|
55
|
-
1. Fork it
|
56
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
57
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
58
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
59
|
-
5. Create new Pull Request
|
60
|
-
|
61
|
-
## License
|
62
|
-
|
63
|
-
Released under the MIT license.
|
64
|
-
|
65
|
-
Copyright, 2019, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
|
66
|
-
Copyright, 2013, by Ilya Grigorik.
|
67
|
-
|
68
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
69
|
-
of this software and associated documentation files (the "Software"), to deal
|
70
|
-
in the Software without restriction, including without limitation the rights
|
71
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
72
|
-
copies of the Software, and to permit persons to whom the Software is
|
73
|
-
furnished to do so, subject to the following conditions:
|
74
|
-
|
75
|
-
The above copyright notice and this permission notice shall be included in
|
76
|
-
all copies or substantial portions of the Software.
|
77
|
-
|
78
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
79
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
80
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
81
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
82
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
83
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
84
|
-
THE SOFTWARE.
|
data/Rakefile
DELETED
data/http-hpack.gemspec
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative "lib/protocol/hpack/version"
|
3
|
-
|
4
|
-
Gem::Specification.new do |spec|
|
5
|
-
spec.name = "protocol-hpack"
|
6
|
-
spec.version = Protocol::HPACK::VERSION
|
7
|
-
spec.licenses = ["MIT"]
|
8
|
-
spec.authors = ["Samuel Williams"]
|
9
|
-
spec.email = ["samuel.williams@oriontransfer.co.nz"]
|
10
|
-
|
11
|
-
spec.summary = "A compresssor and decompressor for HTTP 2.0 HPACK."
|
12
|
-
spec.homepage = "https://github.com/socketry/http-hpack"
|
13
|
-
|
14
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
15
|
-
f.match(%r{^(test|spec|features)/})
|
16
|
-
end
|
17
|
-
|
18
|
-
spec.require_paths = ["lib"]
|
19
|
-
|
20
|
-
spec.add_development_dependency "covered"
|
21
|
-
spec.add_development_dependency "bundler"
|
22
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
-
end
|