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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbb8247fa7eb3b3ae4c8aadda670c34cf6c4b82d4ef9c0c2b9dab708cfcb94f9
4
- data.tar.gz: fafe89f7170284e2c406dcf85a6308bc5bb98ff36d0e38284882c5e53d088370
3
+ metadata.gz: e2fee2fc90ffa4911e2f5eaaee63c513896c1899f3b44043e737e9f3c33da7cf
4
+ data.tar.gz: bda8f069137304a24af10fe3cd112308c377efd739e8cd325b5786a145398a5f
5
5
  SHA512:
6
- metadata.gz: acf91072388222f898e2ed09af677679037b8da6e9730010a43730260134289b580b8be00e8da7c626497ccb7feef11aef7bddf637e6b81577b4b40d3af380fc
7
- data.tar.gz: aa88d7ef93b60650142fa24ad8358f8261e1d0c53822498deee7142e21c7dec0c2af5ef60fb6acf274aff756fa95e14e3f9d3e47267d93c9d2867c14eb4b149e
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
- raise CompressionError, "Index #{index} too large" unless value
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
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Protocol
22
22
  module HPACK
23
- VERSION = "1.3.0"
23
+ VERSION = "1.4.0"
24
24
  end
25
25
  end
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.3.0
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-17 00:00:00.000000000 Z
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.2
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.