Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cc561cc

Browse filesBrowse files
jasnellBethGriggs
authored andcommitted
http2: explicitly disallow nested push streams
Fixes: #19095 Backport-PR-URL: #22850 PR-URL: #22245 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent b66cba0 commit cc561cc
Copy full SHA for cc561cc

File tree

Expand file treeCollapse file tree

5 files changed

+21
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+21
-0
lines changed
Open diff view settings
Collapse file

‎doc/api/errors.md‎

Copy file name to clipboardExpand all lines: doc/api/errors.md
+6Lines changed: 6 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,12 @@ required to send an acknowledgment that it has received and applied the new
775775
be sent at any given time. This error code is used when that limit has been
776776
reached.
777777

778+
<a id="ERR_HTTP2_NESTED_PUSH"></a>
779+
### ERR_HTTP2_NESTED_PUSH
780+
781+
An attempt was made to initiate a new push stream from within a push stream.
782+
Nested push streams are not permitted.
783+
778784
<a id="ERR_HTTP2_NO_SOCKET_MANIPULATION"></a>
779785
### ERR_HTTP2_NO_SOCKET_MANIPULATION
780786

Collapse file

‎doc/api/http2.md‎

Copy file name to clipboardExpand all lines: doc/api/http2.md
+3Lines changed: 3 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,9 @@ Setting the weight of a push stream is not allowed in the `HEADERS` frame. Pass
12611261
a `weight` value to `http2stream.priority` with the `silent` option set to
12621262
`true` to enable server-side bandwidth balancing between concurrent streams.
12631263

1264+
Calling `http2stream.pushStream()` from within a pushed stream is not permitted
1265+
and will throw an error.
1266+
12641267
#### http2stream.respond([headers[, options]])
12651268
<!-- YAML
12661269
added: v8.4.0
Collapse file

‎lib/internal/errors.js‎

Copy file name to clipboardExpand all lines: lib/internal/errors.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ E('ERR_HTTP2_INVALID_SETTING_VALUE',
321321
E('ERR_HTTP2_INVALID_STREAM', 'The stream has been destroyed');
322322
E('ERR_HTTP2_MAX_PENDING_SETTINGS_ACK',
323323
(max) => `Maximum number of pending settings acknowledgements (${max})`);
324+
E('ERR_HTTP2_NESTED_PUSH',
325+
'A push stream cannot initiate another push stream.', Error);
324326
E('ERR_HTTP2_NO_SOCKET_MANIPULATION',
325327
'HTTP/2 sockets should not be directly manipulated (e.g. read and written)');
326328
E('ERR_HTTP2_OUT_OF_STREAMS',
Collapse file

‎lib/internal/http2/core.js‎

Copy file name to clipboardExpand all lines: lib/internal/http2/core.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,6 +2116,8 @@ class ServerHttp2Stream extends Http2Stream {
21162116
pushStream(headers, options, callback) {
21172117
if (!this.pushAllowed)
21182118
throw new errors.Error('ERR_HTTP2_PUSH_DISABLED');
2119+
if (this[kID] % 2 === 0)
2120+
throw new errors.Error('ERR_HTTP2_NESTED_PUSH');
21192121

21202122
const session = this[kSession];
21212123

Collapse file

‎test/parallel/test-http2-server-push-stream.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http2-server-push-stream.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ server.on('stream', common.mustCall((stream, headers) => {
2222
'x-push-data': 'pushed by server',
2323
});
2424
push.end('pushed by server data');
25+
26+
common.expectsError(() => {
27+
push.pushStream({}, common.mustNotCall());
28+
}, {
29+
code: 'ERR_HTTP2_NESTED_PUSH',
30+
type: Error
31+
});
32+
2533
stream.end('test');
2634
}));
2735
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.