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 +4 -4
- data/.travis.yml +1 -0
- data/Gemfile +2 -0
- data/Rakefile +2 -0
- data/http-hpack.gemspec +1 -0
- data/lib/protocol/hpack.rb +2 -0
- data/lib/protocol/hpack/compressor.rb +2 -0
- data/lib/protocol/hpack/context.rb +66 -65
- data/lib/protocol/hpack/decompressor.rb +2 -0
- data/lib/protocol/hpack/error.rb +2 -0
- data/lib/protocol/hpack/huffman.rb +88 -87
- data/lib/protocol/hpack/huffman/machine.rb +2 -0
- data/lib/protocol/hpack/version.rb +3 -1
- data/tasks/huffman.rake +1 -0
- data/tasks/huffman.rb +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4112fcf37f26e859b92e2bcb4dbcdf7fd3df01a29899ecd445d7d983e74e77b1
|
4
|
+
data.tar.gz: fc010fa2660401fbd9f8358eb11c5a74102be25dfdf70c7b2a5e63aa7179f7cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a18ffe445efee527b9a656ffe33a9230799ae89e9eab11d1cb6996f296c16b07050527b9c1b65125ca26fadcc980d7d25773342bed269c1bc3f6dff0ff0fb7cc
|
7
|
+
data.tar.gz: 3214f7efcc5c4cb450571aaf6ba3f7a08023e5d40096390ec77516412865b0f6a9078e239cd570afb3234fe5f2aa124a44fedb1e94b712e741c82d7943b318e4
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/http-hpack.gemspec
CHANGED
@@ -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
|
|
data/lib/protocol/hpack.rb
CHANGED
@@ -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
|
-
#
|
44
|
-
#
|
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
|
-
[
|
48
|
-
[
|
49
|
-
[
|
50
|
-
[
|
51
|
-
[
|
52
|
-
[
|
53
|
-
[
|
54
|
-
[
|
55
|
-
[
|
56
|
-
[
|
57
|
-
[
|
58
|
-
[
|
59
|
-
[
|
60
|
-
[
|
61
|
-
[
|
62
|
-
[
|
63
|
-
[
|
64
|
-
[
|
65
|
-
[
|
66
|
-
[
|
67
|
-
[
|
68
|
-
[
|
69
|
-
[
|
70
|
-
[
|
71
|
-
[
|
72
|
-
[
|
73
|
-
[
|
74
|
-
[
|
75
|
-
[
|
76
|
-
[
|
77
|
-
[
|
78
|
-
[
|
79
|
-
[
|
80
|
-
[
|
81
|
-
[
|
82
|
-
[
|
83
|
-
[
|
84
|
-
[
|
85
|
-
[
|
86
|
-
[
|
87
|
-
[
|
88
|
-
[
|
89
|
-
[
|
90
|
-
[
|
91
|
-
[
|
92
|
-
[
|
93
|
-
[
|
94
|
-
[
|
95
|
-
[
|
96
|
-
[
|
97
|
-
[
|
98
|
-
[
|
99
|
-
[
|
100
|
-
[
|
101
|
-
[
|
102
|
-
[
|
103
|
-
[
|
104
|
-
[
|
105
|
-
[
|
106
|
-
[
|
107
|
-
[
|
108
|
-
].each
|
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
|
#
|
data/lib/protocol/hpack/error.rb
CHANGED
@@ -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(
|
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
|
-
|
55
|
+
buffer.each_byte do |c|
|
56
56
|
(8 / BITS_AT_ONCE - 1).downto(0) do |shift|
|
57
|
-
branch = (
|
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
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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,
|
112
|
+
[0x14, 6],
|
112
113
|
[0x3f8, 10],
|
113
114
|
[0x3f9, 10],
|
114
115
|
[0xffa, 12],
|
115
116
|
[0x1ff9, 13],
|
116
|
-
[0x15,
|
117
|
-
[0xf8,
|
117
|
+
[0x15, 6],
|
118
|
+
[0xf8, 8],
|
118
119
|
[0x7fa, 11],
|
119
120
|
[0x3fa, 10],
|
120
121
|
[0x3fb, 10],
|
121
|
-
[0xf9,
|
122
|
+
[0xf9, 8],
|
122
123
|
[0x7fb, 11],
|
123
|
-
[0xfa,
|
124
|
-
[0x16,
|
125
|
-
[0x17,
|
126
|
-
[0x18,
|
127
|
-
[0x0,
|
128
|
-
[0x1,
|
129
|
-
[0x2,
|
130
|
-
[0x19,
|
131
|
-
[0x1a,
|
132
|
-
[0x1b,
|
133
|
-
[0x1c,
|
134
|
-
[0x1d,
|
135
|
-
[0x1e,
|
136
|
-
[0x1f,
|
137
|
-
[0x5c,
|
138
|
-
[0xfb,
|
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,
|
141
|
+
[0x20, 6],
|
141
142
|
[0xffb, 12],
|
142
143
|
[0x3fc, 10],
|
143
144
|
[0x1ffa, 13],
|
144
|
-
[0x21,
|
145
|
-
[0x5d,
|
146
|
-
[0x5e,
|
147
|
-
[0x5f,
|
148
|
-
[0x60,
|
149
|
-
[0x61,
|
150
|
-
[0x62,
|
151
|
-
[0x63,
|
152
|
-
[0x64,
|
153
|
-
[0x65,
|
154
|
-
[0x66,
|
155
|
-
[0x67,
|
156
|
-
[0x68,
|
157
|
-
[0x69,
|
158
|
-
[0x6a,
|
159
|
-
[0x6b,
|
160
|
-
[0x6c,
|
161
|
-
[0x6d,
|
162
|
-
[0x6e,
|
163
|
-
[0x6f,
|
164
|
-
[0x70,
|
165
|
-
[0x71,
|
166
|
-
[0x72,
|
167
|
-
[0xfc,
|
168
|
-
[0x73,
|
169
|
-
[0xfd,
|
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,
|
175
|
+
[0x22, 6],
|
175
176
|
[0x7ffd, 15],
|
176
|
-
[0x3,
|
177
|
-
[0x23,
|
178
|
-
[0x4,
|
179
|
-
[0x24,
|
180
|
-
[0x5,
|
181
|
-
[0x25,
|
182
|
-
[0x26,
|
183
|
-
[0x27,
|
184
|
-
[0x6,
|
185
|
-
[0x74,
|
186
|
-
[0x75,
|
187
|
-
[0x28,
|
188
|
-
[0x29,
|
189
|
-
[0x2a,
|
190
|
-
[0x7,
|
191
|
-
[0x2b,
|
192
|
-
[0x76,
|
193
|
-
[0x2c,
|
194
|
-
[0x8,
|
195
|
-
[0x9,
|
196
|
-
[0x2d,
|
197
|
-
[0x77,
|
198
|
-
[0x78,
|
199
|
-
[0x79,
|
200
|
-
[0x7a,
|
201
|
-
[0x7b,
|
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
|
#
|
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.
|
25
|
+
VERSION = "1.4.2"
|
24
26
|
end
|
25
27
|
end
|
data/tasks/huffman.rake
CHANGED
data/tasks/huffman.rb
CHANGED
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.
|
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:
|
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.
|
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.
|