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 — quic: convert incoming :status header to number · nodejs/node@88bee43

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • quic.md
  • lib/internal/quic
    • quic.js
  • test/parallel
    • test-quic-h3-callback-errors.mjs
    • test-quic-h3-close-behavior.mjs
    • test-quic-h3-concurrent-requests.mjs
    • test-quic-h3-datagram.mjs
    • test-quic-h3-error-codes.mjs
    • test-quic-h3-goaway.mjs
    • test-quic-h3-header-validation.mjs
    • test-quic-h3-informational-headers.mjs
    • test-quic-h3-origin.mjs
    • test-quic-h3-pending-stream.mjs
    • test-quic-h3-post-filehandle.mjs
    • test-quic-h3-post-request.mjs
    • test-quic-h3-priority.mjs
    • test-quic-h3-qpack-settings.mjs
    • test-quic-h3-request-response.mjs
    • test-quic-h3-settings.mjs
    • test-quic-h3-status-code-type.mjs
    • test-quic-h3-trailing-headers.mjs
    • test-quic-h3-zero-rtt-rejected-settings.mjs
    • test-quic-h3-zero-rtt.mjs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/quic.md‎

Copy file name to clipboardExpand all lines: doc/api/quic.md
+3-2Lines changed: 3 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -3962,8 +3962,9 @@ A few things to note:
39623962
the request is `HEADERS` followed by `END_STREAM`.
39633963
* The `onheaders` callback receives the response pseudo-headers and
39643964
regular headers in a single object with lowercase string keys.
3965-
After the callback returns, the same object is also accessible
3966-
via [`stream.headers`][].
3965+
For incoming headers, the `:status` pseudo-header is converted to
3966+
a `number`, matching HTTP/2 behavior. After the callback returns,
3967+
the same object is also accessible via [`stream.headers`][].
39673968
* Reading `for await (const chunks of stream)` consumes the response
39683969
body. Each iteration yields a `Uint8Array[]` batch of chunks.
39693970
* HTTP semantic helpers (URL parsing, method/status validation,
Collapse file

‎lib/internal/quic/quic.js‎

Copy file name to clipboardExpand all lines: lib/internal/quic/quic.js
+10-5Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,14 +1285,19 @@ function parseHeaderPairs(pairs) {
12851285
assert(pairs.length % 2 === 0);
12861286
const block = { __proto__: null };
12871287
for (let n = 0; n + 1 < pairs.length; n += 2) {
1288-
if (block[pairs[n]] !== undefined) {
1289-
if (ArrayIsArray(block[pairs[n]])) {
1290-
ArrayPrototypePush(block[pairs[n]], pairs[n + 1]);
1288+
const name = pairs[n];
1289+
let value = pairs[n + 1];
1290+
// Match HTTP/2 behavior: incoming :status is exposed as a number.
1291+
if (name === ':status')
1292+
value |= 0;
1293+
if (block[name] !== undefined) {
1294+
if (ArrayIsArray(block[name])) {
1295+
ArrayPrototypePush(block[name], value);
12911296
} else {
1292-
block[pairs[n]] = [block[pairs[n]], pairs[n + 1]];
1297+
block[name] = [block[name], value];
12931298
}
12941299
} else {
1295-
block[pairs[n]] = pairs[n + 1];
1300+
block[name] = value;
12961301
}
12971302
}
12981303
return block;
Collapse file

‎test/parallel/test-quic-h3-callback-errors.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-quic-h3-callback-errors.mjs
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ async function makeServer(onheadersHandler, extraOpts = {}) {
151151
':authority': 'localhost',
152152
},
153153
onheaders: mustCall(function(headers) {
154-
assert.strictEqual(headers[':status'], '200');
154+
assert.strictEqual(headers[':status'], 200);
155155
}),
156156
ontrailers: mustCall(function() {
157157
throw new Error('ontrailers sync error');
@@ -265,7 +265,7 @@ async function makeServer(onheadersHandler, extraOpts = {}) {
265265
':authority': 'localhost',
266266
},
267267
onheaders: mustCall(function(headers) {
268-
assert.strictEqual(headers[':status'], '200');
268+
assert.strictEqual(headers[':status'], 200);
269269
}),
270270
});
271271

Collapse file

‎test/parallel/test-quic-h3-close-behavior.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-quic-h3-close-behavior.mjs
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const decoder = new TextDecoder();
6262
':authority': 'localhost',
6363
},
6464
onheaders: mustCall((headers) => {
65-
assert.strictEqual(headers[':status'], '200');
65+
assert.strictEqual(headers[':status'], 200);
6666
}),
6767
});
6868

@@ -74,7 +74,7 @@ const decoder = new TextDecoder();
7474
':authority': 'localhost',
7575
},
7676
onheaders: mustCall((headers) => {
77-
assert.strictEqual(headers[':status'], '200');
77+
assert.strictEqual(headers[':status'], 200);
7878
}),
7979
});
8080

Collapse file

‎test/parallel/test-quic-h3-concurrent-requests.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-quic-h3-concurrent-requests.mjs
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const requests = paths.map(mustCall(async (path) => {
7272
':authority': 'localhost',
7373
},
7474
onheaders: mustCall((headers) => {
75-
assert.strictEqual(headers[':status'], '200');
75+
assert.strictEqual(headers[':status'], 200);
7676
headersReceived.resolve();
7777
}),
7878
});
Collapse file

‎test/parallel/test-quic-h3-datagram.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-quic-h3-datagram.mjs
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const decoder = new TextDecoder();
8787
':authority': 'localhost',
8888
},
8989
onheaders: mustCall(function(headers) {
90-
assert.strictEqual(headers[':status'], '200');
90+
assert.strictEqual(headers[':status'], 200);
9191
}),
9292
});
9393

@@ -151,7 +151,7 @@ const decoder = new TextDecoder();
151151
':authority': 'localhost',
152152
},
153153
onheaders: mustCall((headers) => {
154-
assert.strictEqual(headers[':status'], '200');
154+
assert.strictEqual(headers[':status'], 200);
155155
}),
156156
});
157157

Collapse file

‎test/parallel/test-quic-h3-error-codes.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-quic-h3-error-codes.mjs
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const decoder = new TextDecoder();
5555
':authority': 'localhost',
5656
},
5757
onheaders: mustCall(function(headers) {
58-
assert.strictEqual(headers[':status'], '200');
58+
assert.strictEqual(headers[':status'], 200);
5959
}),
6060
});
6161

@@ -106,7 +106,7 @@ const decoder = new TextDecoder();
106106
':authority': 'localhost',
107107
},
108108
onheaders: mustCall(function(headers) {
109-
assert.strictEqual(headers[':status'], '200');
109+
assert.strictEqual(headers[':status'], 200);
110110
}),
111111
});
112112

Collapse file

‎test/parallel/test-quic-h3-goaway.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-quic-h3-goaway.mjs
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ dc.subscribe('quic.session.goaway', mustCall((msg) => {
7878
await clientSession.opened;
7979

8080
const onClientHeaders = mustCall(function(headers) {
81-
assert.strictEqual(headers[':status'], '200');
81+
assert.strictEqual(headers[':status'], 200);
8282
if (++clientHeaderCount === 2) {
8383
bothHeadersReceived.resolve();
8484
}
Collapse file

‎test/parallel/test-quic-h3-header-validation.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-quic-h3-header-validation.mjs
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const decoder = new TextDecoder();
9191
},
9292
onheaders: mustCall(function(headers) {
9393
// Client should also receive lowercased response header names.
94-
assert.strictEqual(headers[':status'], '200');
94+
assert.strictEqual(headers[':status'], 200);
9595
assert.strictEqual(headers['content-type'], 'text/html');
9696
assert.strictEqual(headers['x-response-header'], 'ResponseValue');
9797

@@ -148,7 +148,7 @@ const decoder = new TextDecoder();
148148
':authority': 'localhost',
149149
},
150150
onheaders: mustCall((headers) => {
151-
assert.strictEqual(headers[':status'], '204');
151+
assert.strictEqual(headers[':status'], 204);
152152
}),
153153
});
154154

Collapse file

‎test/parallel/test-quic-h3-informational-headers.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-quic-h3-informational-headers.mjs
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dc.subscribe('quic.stream.info', mustCall((msg) => {
3434
assert.ok(msg.stream, 'stream.info should include stream');
3535
assert.ok(msg.session, 'stream.info should include session');
3636
assert.ok(msg.headers, 'stream.info should include headers');
37-
assert.strictEqual(msg.headers[':status'], '103');
37+
assert.strictEqual(msg.headers[':status'], 103);
3838
}));
3939

4040
// quic.stream.headers also fires for the final response headers.
@@ -89,12 +89,12 @@ const stream = await clientSession.createBidirectionalStream({
8989
':authority': 'localhost',
9090
},
9191
oninfo: mustCall(function(headers) {
92-
assert.strictEqual(headers[':status'], '103');
92+
assert.strictEqual(headers[':status'], 103);
9393
assert.strictEqual(headers.link, '</style.css>; rel=preload; as=style');
9494
clientInfoReceived.resolve();
9595
}),
9696
onheaders: mustCall(function(headers) {
97-
assert.strictEqual(headers[':status'], '200');
97+
assert.strictEqual(headers[':status'], 200);
9898
assert.strictEqual(headers['content-type'], 'text/plain');
9999
clientHeadersReceived.resolve();
100100
}),
@@ -107,7 +107,7 @@ const body = await bytes(stream);
107107
assert.strictEqual(decoder.decode(body), responseBody);
108108

109109
// stream.headers should return the final (initial) headers, not 1xx.
110-
assert.strictEqual(stream.headers[':status'], '200');
110+
assert.strictEqual(stream.headers[':status'], 200);
111111

112112
await Promise.all([stream.closed, serverDone.promise]);
113113
await clientSession.close();

0 commit comments

Comments
0 (0)
You are visitor 01402503 — 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.