GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — http2: preserve multiple content-encoding values · nodejs/node@4c9f878

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • http2.md
  • lib/internal/http2
    • util.js
  • test/parallel
    • test-http2-content-encoding.js
    • test-http2-util-headers-list.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/http2.md‎

Copy file name to clipboardExpand all lines: doc/api/http2.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -3679,7 +3679,7 @@ For incoming headers:
36793679
* The `:status` header is converted to `number`.
36803680
* Duplicates of `:status`, `:method`, `:authority`, `:scheme`, `:path`,
36813681
`:protocol`, `age`, `authorization`, `access-control-allow-credentials`,
3682-
`access-control-max-age`, `access-control-request-method`, `content-encoding`,
3682+
`access-control-max-age`, `access-control-request-method`,
36833683
`content-language`, `content-length`, `content-location`, `content-md5`,
36843684
`content-range`, `content-type`, `date`, `dnt`, `etag`, `expires`, `from`,
36853685
`host`, `if-match`, `if-modified-since`, `if-none-match`, `if-range`,
Collapse file

‎lib/internal/http2/util.js‎

Copy file name to clipboardExpand all lines: lib/internal/http2/util.js
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ const {
6262
HTTP2_HEADER_ACCESS_CONTROL_REQUEST_METHOD,
6363
HTTP2_HEADER_AGE,
6464
HTTP2_HEADER_AUTHORIZATION,
65-
HTTP2_HEADER_CONTENT_ENCODING,
6665
HTTP2_HEADER_CONTENT_LANGUAGE,
6766
HTTP2_HEADER_CONTENT_LENGTH,
6867
HTTP2_HEADER_CONTENT_LOCATION,
@@ -134,7 +133,6 @@ const kSingleValueFields = new SafeSet([
134133
HTTP2_HEADER_ACCESS_CONTROL_REQUEST_METHOD,
135134
HTTP2_HEADER_AGE,
136135
HTTP2_HEADER_AUTHORIZATION,
137-
HTTP2_HEADER_CONTENT_ENCODING,
138136
HTTP2_HEADER_CONTENT_LANGUAGE,
139137
HTTP2_HEADER_CONTENT_LENGTH,
140138
HTTP2_HEADER_CONTENT_LOCATION,
Collapse file

‎test/parallel/test-http2-content-encoding.js‎

Copy file name to clipboard
+57Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
if (!common.hasCrypto)
5+
common.skip('missing crypto');
6+
const assert = require('node:assert/strict');
7+
const http2 = require('node:http2');
8+
const { once } = require('node:events');
9+
10+
// Content-Encoding is a list (RFC 9110 section 8.4). Preserve all codings
11+
// in their original order, regardless of single-value field validation.
12+
async function test(options, value) {
13+
const values = Array.isArray(value) ? value : [value];
14+
const expectedRaw = values.flatMap((v) => ['content-encoding', v]);
15+
const expected = values.join(', ');
16+
17+
function check(headers, rawHeaders) {
18+
assert.strictEqual(headers['content-encoding'], expected);
19+
const raw = [];
20+
for (let i = 0; i < rawHeaders.length; i += 2) {
21+
if (rawHeaders[i] === 'content-encoding')
22+
raw.push(rawHeaders[i], rawHeaders[i + 1]);
23+
}
24+
assert.deepStrictEqual(raw, expectedRaw);
25+
}
26+
27+
const server = http2.createServer(options);
28+
server.on('stream', common.mustCall((stream, headers, flags, rawHeaders) => {
29+
check(headers, rawHeaders);
30+
stream.respond({ 'content-encoding': value });
31+
stream.end();
32+
}));
33+
server.listen(0);
34+
await once(server, 'listening');
35+
36+
const client = http2.connect(`http://localhost:${server.address().port}`, options);
37+
const req = client.request({ 'content-encoding': value });
38+
req.on('response', common.mustCall((headers, flags, rawHeaders) => {
39+
check(headers, rawHeaders);
40+
}));
41+
req.resume();
42+
req.end();
43+
await once(req, 'end');
44+
client.close();
45+
await once(client, 'close');
46+
await new Promise((resolve) => server.close(resolve));
47+
}
48+
49+
(async () => {
50+
for (const options of [{}, { strictSingleValueFields: true },
51+
{ strictSingleValueFields: false }]) {
52+
for (const value of ['gzip', 'gzip, br', ['gzip', 'br'],
53+
['br', 'gzip'], ['gzip', 'gzip']]) {
54+
await test(options, value);
55+
}
56+
}
57+
})().then(common.mustCall());
Collapse file

‎test/parallel/test-http2-util-headers-list.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http2-util-headers-list.js
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ const {
219219
HTTP2_HEADER_ACCESS_CONTROL_REQUEST_METHOD,
220220
HTTP2_HEADER_AGE,
221221
HTTP2_HEADER_AUTHORIZATION,
222-
HTTP2_HEADER_CONTENT_ENCODING,
223222
HTTP2_HEADER_CONTENT_LANGUAGE,
224223
HTTP2_HEADER_CONTENT_LENGTH,
225224
HTTP2_HEADER_CONTENT_LOCATION,
@@ -267,6 +266,7 @@ const {
267266
});
268267

269268
[
269+
HTTP2_HEADER_CONTENT_ENCODING,
270270
HTTP2_HEADER_ACCEPT_CHARSET,
271271
HTTP2_HEADER_ACCEPT_ENCODING,
272272
HTTP2_HEADER_ACCEPT_LANGUAGE,
@@ -419,3 +419,10 @@ assert.strictEqual(getAuthority({
419419
assert.strictEqual(headers.age, '10');
420420
assert.strictEqual(headers['x-multi'], 'first, second');
421421
}
422+
423+
// Content-Encoding is an ordered list, including repeated content codings.
424+
for (const values of [['gzip', 'br'], ['br', 'gzip'], ['gzip', 'gzip']]) {
425+
const rawHeaders = values.flatMap((value) => ['content-encoding', value]);
426+
assert.strictEqual(toHeaderObject(rawHeaders)['content-encoding'],
427+
values.join(', '));
428+
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.