GeezerVison is showing github.com — http2: explicitly disallow nested push streams · nodejs/node@cc561cc
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
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 number | Diff line number | Diff line change |
|---|
@@ -775,6 +775,12 @@ required to send an acknowledgment that it has received and applied the new |
775 | 775 | be sent at any given time. This error code is used when that limit has been |
776 | 776 | reached. |
777 | 777 |
|
| 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 | + |
778 | 784 | <a id="ERR_HTTP2_NO_SOCKET_MANIPULATION"></a> |
779 | 785 | ### ERR_HTTP2_NO_SOCKET_MANIPULATION |
780 | 786 |
|
|
Collapse file
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 number | Diff line number | Diff line change |
|---|
@@ -1261,6 +1261,9 @@ Setting the weight of a push stream is not allowed in the `HEADERS` frame. Pass |
1261 | 1261 | a `weight` value to `http2stream.priority` with the `silent` option set to |
1262 | 1262 | `true` to enable server-side bandwidth balancing between concurrent streams. |
1263 | 1263 |
|
| 1264 | +Calling `http2stream.pushStream()` from within a pushed stream is not permitted |
| 1265 | +and will throw an error. |
| 1266 | + |
1264 | 1267 | #### http2stream.respond([headers[, options]]) |
1265 | 1268 | <!-- YAML |
1266 | 1269 | added: v8.4.0 |
|
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/errors.js +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -321,6 +321,8 @@ E('ERR_HTTP2_INVALID_SETTING_VALUE', |
321 | 321 | E('ERR_HTTP2_INVALID_STREAM', 'The stream has been destroyed'); |
322 | 322 | E('ERR_HTTP2_MAX_PENDING_SETTINGS_ACK', |
323 | 323 | (max) => `Maximum number of pending settings acknowledgements (${max})`); |
| 324 | +E('ERR_HTTP2_NESTED_PUSH', |
| 325 | + 'A push stream cannot initiate another push stream.', Error); |
324 | 326 | E('ERR_HTTP2_NO_SOCKET_MANIPULATION', |
325 | 327 | 'HTTP/2 sockets should not be directly manipulated (e.g. read and written)'); |
326 | 328 | E('ERR_HTTP2_OUT_OF_STREAMS', |
|
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/http2/core.js +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2116,6 +2116,8 @@ class ServerHttp2Stream extends Http2Stream { |
2116 | 2116 | pushStream(headers, options, callback) { |
2117 | 2117 | if (!this.pushAllowed) |
2118 | 2118 | throw new errors.Error('ERR_HTTP2_PUSH_DISABLED'); |
| 2119 | + if (this[kID] % 2 === 0) |
| 2120 | + throw new errors.Error('ERR_HTTP2_NESTED_PUSH'); |
2119 | 2121 |
|
2120 | 2122 | const session = this[kSession]; |
2121 | 2123 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-http2-server-push-stream.js +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -22,6 +22,14 @@ server.on('stream', common.mustCall((stream, headers) => { |
22 | 22 | 'x-push-data': 'pushed by server', |
23 | 23 | }); |
24 | 24 | 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 | + |
25 | 33 | stream.end('test'); |
26 | 34 | })); |
27 | 35 | } |
|