http: assert parser.consume argument's type · nodejs/node@e65c9ec
1+'use strict';
2+const common = require('../common');
3+const assert = require('assert');
4+const http = require('http');
5+const spawn = require('child_process').spawn;
6+7+if (process.argv[2] === 'child') {
8+const server = http.createServer(common.mustCall((req, res) => {
9+res.end('hello');
10+}));
11+12+server.listen(0, common.mustCall((s) => {
13+const rr = http.get(
14+{ port: server.address().port },
15+common.mustCall((d) => {
16+// This bad input (0) should abort the parser and the process
17+rr.parser.consume(0);
18+server.close();
19+}));
20+}));
21+} else {
22+const child = spawn(process.execPath, [__filename, 'child'],
23+{ stdio: 'inherit' });
24+child.on('exit', common.mustCall((code, signal) => {
25+assert(common.nodeProcessAborted(code, signal),
26+'process should have aborted, but did not');
27+}));
28+}