protocol-hpack 1.4.2 → 1.4.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4112fcf37f26e859b92e2bcb4dbcdf7fd3df01a29899ecd445d7d983e74e77b1
4
- data.tar.gz: fc010fa2660401fbd9f8358eb11c5a74102be25dfdf70c7b2a5e63aa7179f7cb
3
+ metadata.gz: 3192190834a35550921cbff8e50482499716791371f521a77c3f7c4b5a0efcff
4
+ data.tar.gz: 40d443b19eaac26aaaaae63da3baab5ae384246804643fdc7fb01f5455595dc3
5
5
  SHA512:
6
- metadata.gz: a18ffe445efee527b9a656ffe33a9230799ae89e9eab11d1cb6996f296c16b07050527b9c1b65125ca26fadcc980d7d25773342bed269c1bc3f6dff0ff0fb7cc
7
- data.tar.gz: 3214f7efcc5c4cb450571aaf6ba3f7a08023e5d40096390ec77516412865b0f6a9078e239cd570afb3234fe5f2aa124a44fedb1e94b712e741c82d7943b318e4
6
+ metadata.gz: c19a7524c1a544016e0feb7d88099a67fbccf3fe200214f7bc21639512da55e72a9e3442c8917f69fec1568a3027487e701a2f1e99deb652942ebae54c4752a7
7
+ data.tar.gz: 3f105d7bba7111585325db6bc8f414c34366bfb189f2263fa497e8ec53ed1502c3694c0dcd6749151fb10456c52a5a333daa9b7f5f8b362026d8be745c568375
checksums.yaml.gz.sig ADDED
Binary file
@@ -1,25 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- # Copyrigh, 2013, by Ilya Grigorik.
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, 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.
23
14
 
24
15
  require_relative 'context'
25
16
  require_relative 'huffman'
@@ -63,10 +54,6 @@ module Protocol
63
54
  attr :context
64
55
  attr :offset
65
56
 
66
- def write_byte(byte)
67
- @buffer << byte.chr
68
- end
69
-
70
57
  def write_bytes(bytes)
71
58
  @buffer << bytes
72
59
  end
@@ -1,25 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- # Copyrigh, 2013, by Ilya Grigorik.
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
  require_relative 'huffman'
25
7
 
@@ -30,12 +12,17 @@ module Protocol
30
12
  # - http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-10
31
13
  module HPACK
32
14
  # Header representation as defined by the spec.
15
+ NO_INDEX_TYPE = {prefix: 4, pattern: 0x00}.freeze
16
+ NEVER_INDEXED_TYPE = {prefix: 4, pattern: 0x10}.freeze
17
+ CHANGE_TABLE_SIZE_TYPE = {prefix: 5, pattern: 0x20}.freeze
18
+ INCREMENTAL_TYPE = {prefix: 6, pattern: 0x40}.freeze
19
+ INDEXED_TYPE = {prefix: 7, pattern: 0x80}.freeze
33
20
  HEADER_REPRESENTATION = {
34
- indexed: {prefix: 7, pattern: 0x80},
35
- incremental: {prefix: 6, pattern: 0x40},
36
- no_index: {prefix: 4, pattern: 0x00},
37
- never_indexed: {prefix: 4, pattern: 0x10},
38
- change_table_size: {prefix: 5, pattern: 0x20},
21
+ indexed: INDEXED_TYPE,
22
+ incremental: INCREMENTAL_TYPE,
23
+ no_index: NO_INDEX_TYPE,
24
+ never_indexed: NEVER_INDEXED_TYPE,
25
+ change_table_size: CHANGE_TABLE_SIZE_TYPE
39
26
  }
40
27
 
41
28
  # To decompress header blocks, a decoder only needs to maintain a
@@ -298,8 +285,8 @@ module Protocol
298
285
 
299
286
  # Returns current table size in octets
300
287
  # @return [Integer]
301
- def current_table_size
302
- @table.inject(0) {|r, (k, v)| r + k.bytesize + v.bytesize + 32}
288
+ def compute_current_table_size
289
+ @table.sum { |k, v| k.bytesize + v.bytesize + 32 }
303
290
  end
304
291
 
305
292
  private
@@ -314,6 +301,11 @@ module Protocol
314
301
  command.freeze
315
302
 
316
303
  @table.unshift(command)
304
+ @current_table_size += entry_size(command)
305
+ end
306
+
307
+ def entry_size(e)
308
+ e[0].bytesize + e[1].bytesize + 32
317
309
  end
318
310
 
319
311
  # To keep the dynamic table size lower than or equal to @table_size,
@@ -322,14 +314,16 @@ module Protocol
322
314
  # @param command [Hash]
323
315
  # @return [Boolean] whether +command+ fits in the dynamic table.
324
316
  def size_check(command)
325
- cursize = current_table_size
317
+
318
+ @current_table_size ||= compute_current_table_size
319
+
326
320
  cmdsize = command.nil? ? 0 : command[0].bytesize + command[1].bytesize + 32
327
321
 
328
- while cursize + cmdsize > @table_size
322
+ while @current_table_size + cmdsize > @table_size
329
323
  break if @table.empty?
330
324
 
331
325
  e = @table.pop
332
- cursize -= e[0].bytesize + e[1].bytesize + 32
326
+ @current_table_size -= e[0].bytesize + e[1].bytesize + 32
333
327
  end
334
328
 
335
329
  cmdsize <= @table_size
@@ -1,25 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- # Copyrigh, 2013, by Ilya Grigorik.
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
  require_relative 'context'
25
7
  require_relative 'huffman'
@@ -30,6 +12,9 @@ module Protocol
30
12
  # context of the opposing peer. Decompressor must be initialized with
31
13
  # appropriate starting context based on local role: client or server.
32
14
  class Decompressor
15
+
16
+ MASK_SHIFT_4 = (~0x0 >> 4) << 4
17
+
33
18
  def initialize(buffer, context = Context.new, table_size_limit: nil)
34
19
  @buffer = buffer
35
20
  @context = context
@@ -116,30 +101,80 @@ module Protocol
116
101
  pattern = peek_byte
117
102
 
118
103
  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
104
 
124
- raise CompressionError unless header[:type]
105
+ type = nil
106
+
107
+ # (pattern & MASK_SHIFT_4) clears bottom 4 bits,
108
+ # equivalent to (pattern >> 4) << 4. For the
109
+ # no-index and never-indexed type we only need to clear
110
+ # the bottom 4 bits (as specified by NO_INDEX_TYPE[:prefix])
111
+ # so we directly check against NO_INDEX_TYPE[:pattern].
112
+ # But for change-table-size, incremental, and indexed
113
+ # we must clear 5,6, and 7 bits respectively.
114
+ # Consider indexed where we need to clear 7 bits.
115
+ # Since (pattern & MASK_SHIFT_4)'s bottom 4 bits are cleared
116
+ # you can visualize it as
117
+ #
118
+ # INDEXED_TYPE[:pattern] = <some bits> 0 0 0 0 0 0 0
119
+ # ^^^^^^^^^^^^^^^^ 7 bits
120
+ # (pattern & MASK_SHIFT_4) = <pattern bits> b1 b2 b3 0 0 0 0
121
+ #
122
+ # Computing equality after masking bottom 7 bits (i.e., set b1 = b2 = b3 = 0)
123
+ # is the same as checking equality against
124
+ # <some bits> x1 x2 x3 0 0 0 0
125
+ # For *every* possible value of x1, x2, x3 (that is, 2^3 = 8 values).
126
+ # INDEXED_TYPE[:pattern] = 0x80, so we check against 0x80, 0x90 = 0x80 + (0b001 << 4)
127
+ # 0xa0 = 0x80 + (0b001 << 5), ..., 0xf0 = 0x80 + (0b111 << 4).
128
+ # While not the most readable, we have written out everything as constant literals
129
+ # so Ruby can optimize this case-when to a hash lookup.
130
+ #
131
+ # There's no else case as this list is exhaustive.
132
+ # (0..255).map { |x| (x & -16).to_s(16) }.uniq will show this
133
+
134
+ case (pattern & MASK_SHIFT_4)
135
+ when 0x00
136
+ header[:type] = :no_index
137
+ type = NO_INDEX_TYPE
138
+ when 0x10
139
+ header[:type] = :never_indexed
140
+ type = NEVER_INDEXED_TYPE
141
+ # checking if (pattern >> 5) << 5 == 0x20
142
+ # Since we cleared bottom 4 bits, the 5th
143
+ # bit can be either 0 or 1, so check both
144
+ # cases.
145
+ when 0x20, 0x30
146
+ header[:type] = :change_table_size
147
+ type = CHANGE_TABLE_SIZE_TYPE
148
+ # checking if (pattern >> 6) << 6 == 0x40
149
+ # Same logic as above, but now over the 4
150
+ # possible combinations of 2 bits (5th, 6th)
151
+ when 0x40, 0x50, 0x60, 0x70
152
+ header[:type] = :incremental
153
+ type = INCREMENTAL_TYPE
154
+ # checking if (pattern >> 7) << 7 == 0x80
155
+ when 0x80, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0
156
+ header[:type] = :indexed
157
+ type = INDEXED_TYPE
158
+ end
125
159
 
126
- header[:name] = read_integer(type[:prefix])
160
+ header_name = read_integer(type[:prefix])
127
161
 
128
162
  case header[:type]
129
163
  when :indexed
130
- raise CompressionError if header[:name].zero?
131
- header[:name] -= 1
164
+ raise CompressionError if header_name.zero?
165
+ header[:name] = header_name - 1
132
166
  when :change_table_size
133
- header[:value] = header[:name]
167
+ header[:name] = header_name
168
+ header[:value] = header_name
134
169
 
135
170
  if @table_size_limit and header[:value] > @table_size_limit
136
171
  raise CompressionError, "Table size #{header[:value]} exceeds limit #{@table_size_limit}!"
137
172
  end
138
173
  else
139
- if (header[:name]).zero?
174
+ if header_name.zero?
140
175
  header[:name] = read_string
141
176
  else
142
- header[:name] -= 1
177
+ header[:name] = header_name - 1
143
178
  end
144
179
 
145
180
  header[:value] = read_string
@@ -1,25 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- # Copyrigh, 2013, by Ilya Grigorik.
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
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- # Copyrigh, 2013, by Ilya Grigorik.
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,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- # Copyrigh, 2013, by Ilya Grigorik.
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, 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.
23
9
 
24
10
  require_relative 'huffman/machine'
25
11
  require_relative 'error'
@@ -1,27 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
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.4.2"
8
+ VERSION = "1.4.3"
26
9
  end
27
10
  end
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
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,35 @@
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
+
19
+ Permission is hereby granted, free of charge, to any person obtaining a copy
20
+ of this software and associated documentation files (the "Software"), to deal
21
+ in the Software without restriction, including without limitation the rights
22
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23
+ copies of the Software, and to permit persons to whom the Software is
24
+ furnished to do so, subject to the following conditions:
25
+
26
+ The above copyright notice and this permission notice shall be included in all
27
+ copies or substantial portions of the Software.
28
+
29
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
+ 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
+ ## Contributing
14
+
15
+ We welcome contributions to this project.
16
+
17
+ 1. Fork it.
18
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
19
+ 3. Commit your changes (`git commit -am 'Add some feature'`).
20
+ 4. Push to the branch (`git push origin my-new-feature`).
21
+ 5. Create new Pull Request.
22
+
23
+ ### Developer Certificate of Origin
24
+
25
+ This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
26
+
27
+ ### Contributor Covenant
28
+
29
+ This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
30
+
31
+ ## See Also
32
+
33
+ - [protocol-http2](https://github.com/socketry/protocol-http2) - Provides an HTTP/2 client and server implementation.
34
+ - [async-http](https://github.com/socketry/async-http) - Provides a complete HTTP client and server implementation on top of Async.
data/tasks/huffman.rb CHANGED
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
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
+
3
10
  require_relative '../lib/http/hpack/huffman'
4
11
 
5
12
  require 'set'
@@ -102,26 +109,10 @@ module Huffman
102
109
 
103
110
  File.open(File.expand_path('../lib/http/hpack/huffman/machine.rb', File.dirname(__FILE__)), 'w') do |f|
104
111
  f.print <<HEADER
105
- # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
106
- # Copyrigh, 2013, by Ilya Grigorik.
107
- #
108
- # Permission is hereby granted, free of charge, to any person obtaining a copy
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.
112
+ # frozen_string_literal: true
113
+
114
+ # Released under the MIT License.
115
+ # Copyright, 2018-2024, by Samuel Williams.
125
116
 
126
117
  # Machine generated Huffman decoder state machine.
127
118
  # DO NOT EDIT THIS FILE.
data.tar.gz.sig ADDED
Binary file
metadata CHANGED
@@ -1,87 +1,64 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-hpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
- autorequire:
8
+ - Ilya Grigorik
9
+ - Tamir Duberstein
10
+ - Kaoru Maeda
11
+ - Tiago Cardoso
12
+ - Byron Formwalt
13
+ - Cyril Roelandt
14
+ - Daniel Morrison
15
+ - Felix Yan
16
+ - George Ulmer
17
+ - Jingyi Chen
18
+ - Justin Mazzocchi
19
+ - Kenichi Nakamura
20
+ - Kien Nguyen Trung
21
+ - Olle Jonsson
22
+ autorequire:
9
23
  bindir: bin
10
- cert_chain: []
11
- date: 2020-02-01 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: covered
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
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:
24
+ cert_chain:
25
+ - |
26
+ -----BEGIN CERTIFICATE-----
27
+ MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
28
+ ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
29
+ CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
30
+ MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
31
+ MBsGCgmSJomT8ixkARkWDW9yaW9udHJhbnNmZXIxEjAQBgoJkiaJk/IsZAEZFgJj
32
+ bzESMBAGCgmSJomT8ixkARkWAm56MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIB
33
+ igKCAYEAomvSopQXQ24+9DBB6I6jxRI2auu3VVb4nOjmmHq7XWM4u3HL+pni63X2
34
+ 9qZdoq9xt7H+RPbwL28LDpDNflYQXoOhoVhQ37Pjn9YDjl8/4/9xa9+NUpl9XDIW
35
+ sGkaOY0eqsQm1pEWkHJr3zn/fxoKPZPfaJOglovdxf7dgsHz67Xgd/ka+Wo1YqoE
36
+ e5AUKRwUuvaUaumAKgPH+4E4oiLXI4T1Ff5Q7xxv6yXvHuYtlMHhYfgNn8iiW8WN
37
+ XibYXPNP7NtieSQqwR/xM6IRSoyXKuS+ZNGDPUUGk8RoiV/xvVN4LrVm9upSc0ss
38
+ RZ6qwOQmXCo/lLcDUxJAgG95cPw//sI00tZan75VgsGzSWAOdjQpFM0l4dxvKwHn
39
+ tUeT3ZsAgt0JnGqNm2Bkz81kG4A2hSyFZTFA8vZGhp+hz+8Q573tAR89y9YJBdYM
40
+ zp0FM4zwMNEUwgfRzv1tEVVUEXmoFCyhzonUUw4nE4CFu/sE3ffhjKcXcY//qiSW
41
+ xm4erY3XAgMBAAGjgZowgZcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
42
+ BBYEFO9t7XWuFf2SKLmuijgqR4sGDlRsMC4GA1UdEQQnMCWBI3NhbXVlbC53aWxs
43
+ aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWBI3NhbXVlbC53aWxs
44
+ aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEBCwUAA4IBgQB5sxkE
45
+ cBsSYwK6fYpM+hA5B5yZY2+L0Z+27jF1pWGgbhPH8/FjjBLVn+VFok3CDpRqwXCl
46
+ xCO40JEkKdznNy2avOMra6PFiQyOE74kCtv7P+Fdc+FhgqI5lMon6tt9rNeXmnW/
47
+ c1NaMRdxy999hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
48
+ 8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
49
+ JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
50
+ eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
51
+ Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
52
+ voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
53
+ -----END CERTIFICATE-----
54
+ date: 2024-03-12 00:00:00.000000000 Z
55
+ dependencies: []
56
+ description:
70
57
  email:
71
- - samuel.williams@oriontransfer.co.nz
72
58
  executables: []
73
59
  extensions: []
74
60
  extra_rdoc_files: []
75
61
  files:
76
- - ".editorconfig"
77
- - ".gitignore"
78
- - ".gitmodules"
79
- - ".rspec"
80
- - ".travis.yml"
81
- - Gemfile
82
- - README.md
83
- - Rakefile
84
- - http-hpack.gemspec
85
62
  - lib/protocol/hpack.rb
86
63
  - lib/protocol/hpack/compressor.rb
87
64
  - lib/protocol/hpack/context.rb
@@ -90,13 +67,16 @@ files:
90
67
  - lib/protocol/hpack/huffman.rb
91
68
  - lib/protocol/hpack/huffman/machine.rb
92
69
  - lib/protocol/hpack/version.rb
70
+ - license.md
71
+ - readme.md
93
72
  - tasks/huffman.rake
94
73
  - tasks/huffman.rb
95
74
  homepage: https://github.com/socketry/http-hpack
96
75
  licenses:
97
76
  - MIT
98
- metadata: {}
99
- post_install_message:
77
+ metadata:
78
+ documentation_uri: https://socketry.github.io/protocol-hpack/
79
+ post_install_message:
100
80
  rdoc_options: []
101
81
  require_paths:
102
82
  - lib
@@ -104,15 +84,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
104
84
  requirements:
105
85
  - - ">="
106
86
  - !ruby/object:Gem::Version
107
- version: '0'
87
+ version: '3.0'
108
88
  required_rubygems_version: !ruby/object:Gem::Requirement
109
89
  requirements:
110
90
  - - ">="
111
91
  - !ruby/object:Gem::Version
112
92
  version: '0'
113
93
  requirements: []
114
- rubygems_version: 3.1.2
115
- signing_key:
94
+ rubygems_version: 3.5.3
95
+ signing_key:
116
96
  specification_version: 4
117
- summary: A compresssor and decompressor for HTTP 2.0 HPACK.
97
+ summary: A compresssor and decompressor for HTTP/2's HPACK format.
118
98
  test_files: []
metadata.gz.sig ADDED
Binary file
data/.editorconfig DELETED
@@ -1,6 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- indent_style = tab
5
- indent_size = 2
6
-
data/.gitignore DELETED
@@ -1,12 +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
data/.gitmodules DELETED
@@ -1,3 +0,0 @@
1
- [submodule "spec/protocol/hpack/fixtures"]
2
- path = spec/protocol/hpack/fixtures
3
- url = https://github.com/http2jp/hpack-test-case.git
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --warnings
3
- --require spec_helper
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
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- # Specify your gem's dependencies in protocol-hpack.gemspec
6
- gemspec
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
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- task :default => :spec
9
-
10
- load *Dir["tasks/*.rake"]
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