MCPcopy Index your code
hub / github.com/nodejs/node / onStream

Function onStream

test/parallel/test-http2-info-headers.js:19–61  ·  view source on GitHub ↗
(stream, headers, flags)

Source from the content-addressed store, hash-verified

17 /^Cannot specify additional headers after response initiated$/;
18
19function onStream(stream, headers, flags) {
20
21 assert.throws(() => stream.additionalHeaders({ ':status': 201 }),
22 {
23 code: 'ERR_HTTP2_INVALID_INFO_STATUS',
24 name: 'RangeError',
25 message: /^Invalid informational status code: 201$/
26 });
27
28 assert.throws(() => stream.additionalHeaders({ ':status': 101 }),
29 {
30 code: 'ERR_HTTP2_STATUS_101',
31 name: 'Error',
32 message: status101regex
33 });
34
35 assert.throws(
36 () => stream.additionalHeaders({ ':method': 'POST' }),
37 {
38 code: 'ERR_HTTP2_INVALID_PSEUDOHEADER',
39 name: 'TypeError',
40 message: '":method" is an invalid pseudoheader or is used incorrectly'
41 }
42 );
43
44 // Can send more than one
45 stream.additionalHeaders({ ':status': 100 });
46 stream.additionalHeaders({ ':status': 100 });
47
48 stream.respond({
49 'content-type': 'text/html',
50 ':status': 200
51 });
52
53 assert.throws(() => stream.additionalHeaders({ abc: 123 }),
54 {
55 code: 'ERR_HTTP2_HEADERS_AFTER_RESPOND',
56 name: 'Error',
57 message: afterRespondregex
58 });
59
60 stream.end('hello world');
61}
62
63server.listen(0);
64

Callers

nothing calls this directly

Calls 3

additionalHeadersMethod · 0.80
respondMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…