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 8d595bb

Browse filesBrowse files
XadillaXaddaleax
authored andcommitted
test: check endless loop while writing empty string
Refs: #18673 PR-URL: #18924 Refs: #18673 Refs: https://github.com/nodejs/node/blob/v9.5.0/src/node_http2.cc#L1481-L1484 Refs: https://github.com/nodejs/node/blob/v9.5.0/lib/_http_outgoing.js#L659-L661 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 8bc930c commit 8d595bb
Copy full SHA for 8d595bb

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

+54
-0
lines changed
Open diff view settings
Collapse file
+54Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
'use strict';
2+
3+
const assert = require('assert');
4+
const http2 = require('http2');
5+
6+
const common = require('../common');
7+
if (!common.hasCrypto)
8+
common.skip('missing crypto');
9+
10+
for (const chunkSequence of [
11+
[ '' ],
12+
[ '', '' ]
13+
]) {
14+
const server = http2.createServer();
15+
server.on('stream', common.mustCall((stream, headers, flags) => {
16+
stream.respond({ 'content-type': 'text/html' });
17+
18+
let data = '';
19+
stream.on('data', common.mustNotCall((chunk) => {
20+
data += chunk.toString();
21+
}));
22+
stream.on('end', common.mustCall(() => {
23+
stream.end(`"${data}"`);
24+
}));
25+
}));
26+
27+
server.listen(0, common.mustCall(() => {
28+
const port = server.address().port;
29+
const client = http2.connect(`http://localhost:${port}`);
30+
31+
const req = client.request({
32+
':method': 'POST',
33+
':path': '/'
34+
});
35+
36+
req.on('response', common.mustCall((headers) => {
37+
assert.strictEqual(headers[':status'], 200);
38+
assert.strictEqual(headers['content-type'], 'text/html');
39+
}));
40+
41+
let data = '';
42+
req.setEncoding('utf8');
43+
req.on('data', common.mustCallAtLeast((d) => data += d));
44+
req.on('end', common.mustCall(() => {
45+
assert.strictEqual(data, '""');
46+
server.close();
47+
client.close();
48+
}));
49+
50+
for (const chunk of chunkSequence)
51+
req.write(chunk);
52+
req.end();
53+
}));
54+
}

0 commit comments

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