protocol-hpack 1.3.0 → 1.4.0
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 +4 -4
- data/lib/protocol/hpack/compressor.rb +15 -5
- data/lib/protocol/hpack/context.rb +11 -2
- data/lib/protocol/hpack/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2fee2fc90ffa4911e2f5eaaee63c513896c1899f3b44043e737e9f3c33da7cf
|
4
|
+
data.tar.gz: bda8f069137304a24af10fe3cd112308c377efd739e8cd325b5786a145398a5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fdb870d4cd06c50dabd5904ac5f02889269dbd41a014a6631f2d209b0dc82343f5dd9e70dd5b85de78837aa21c81a8011c30e7d9c81a98c11fd7c5cc5a47d03
|
7
|
+
data.tar.gz: 4c5c287482c394ecbf019a41f0ce8030e1128fe8e39505e862aa8c8d5ba817eae4377b6b4a41bcae9500b9fcb3b86c76496ec494e71ebd29d4224c00f79bd59f
|
@@ -48,15 +48,19 @@ module Protocol
|
|
48
48
|
|
49
49
|
# Responsible for encoding header key-value pairs using HPACK algorithm.
|
50
50
|
class Compressor
|
51
|
-
def initialize(buffer, context = Context.new)
|
51
|
+
def initialize(buffer, context = Context.new, table_size_limit: nil)
|
52
52
|
@buffer = buffer
|
53
53
|
@context = context
|
54
|
+
|
55
|
+
@table_size_limit = table_size_limit
|
54
56
|
end
|
55
|
-
|
57
|
+
|
58
|
+
attr :table_size_limit
|
59
|
+
|
56
60
|
attr :buffer
|
57
61
|
attr :context
|
58
62
|
attr :offset
|
59
|
-
|
63
|
+
|
60
64
|
def write_byte(byte)
|
61
65
|
@buffer << byte.chr
|
62
66
|
end
|
@@ -64,7 +68,7 @@ module Protocol
|
|
64
68
|
def write_bytes(bytes)
|
65
69
|
@buffer << bytes
|
66
70
|
end
|
67
|
-
|
71
|
+
|
68
72
|
# Encodes provided value via integer representation.
|
69
73
|
# - http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-10#section-5.1
|
70
74
|
#
|
@@ -179,7 +183,13 @@ module Protocol
|
|
179
183
|
#
|
180
184
|
# @param headers [Array] +[[name, value], ...]+
|
181
185
|
# @return [Buffer]
|
182
|
-
def encode(headers)
|
186
|
+
def encode(headers, table_size = @table_size_limit)
|
187
|
+
if table_size and table_size != @context.table_size
|
188
|
+
command = @context.change_table_size(table_size)
|
189
|
+
|
190
|
+
write_header(command)
|
191
|
+
end
|
192
|
+
|
183
193
|
commands = @context.encode(headers)
|
184
194
|
|
185
195
|
commands.each do |command|
|
@@ -151,7 +151,9 @@ module Protocol
|
|
151
151
|
# NOTE: index is zero-based in this module.
|
152
152
|
value = STATIC_TABLE[index] || @table[index - STATIC_TABLE.size]
|
153
153
|
|
154
|
-
|
154
|
+
if value.nil?
|
155
|
+
raise CompressionError, "Index #{index} too large!"
|
156
|
+
end
|
155
157
|
|
156
158
|
return value
|
157
159
|
end
|
@@ -285,7 +287,14 @@ module Protocol
|
|
285
287
|
@table_size = size
|
286
288
|
size_check(nil)
|
287
289
|
end
|
288
|
-
|
290
|
+
|
291
|
+
def change_table_size(size)
|
292
|
+
self.table_size = size
|
293
|
+
|
294
|
+
# The command to resize the table:
|
295
|
+
return {type: :change_table_size, value: size}
|
296
|
+
end
|
297
|
+
|
289
298
|
# Returns current table size in octets
|
290
299
|
# @return [Integer]
|
291
300
|
def current_table_size
|
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
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: covered
|
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
|
-
rubygems_version: 3.0.
|
113
|
+
rubygems_version: 3.0.3
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: A compresssor and decompressor for HTTP 2.0 HPACK.
|