http: do not override user-provided options object · nodejs/node@a325746 · GitHub
Skip to content

Commit a325746

Browse files
KuthorXRafaelGSS
authored andcommitted
http: do not override user-provided options object
PR-URL: #33633 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent b2135ae commit a325746

3 files changed

Lines changed: 49 additions & 9 deletions

File tree

lib/_http_client.js

Lines changed: 6 additions & 9 deletions
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const http = require('http');
5+
const assert = require('assert');
6+
7+
{
8+
const server = http.createServer(common.mustCall((req, res) => {
9+
res.writeHead(200);
10+
res.end('hello world');
11+
})).listen(0, '127.0.0.1');
12+
13+
server.on('listening', common.mustCall(() => {
14+
const req = new http.ClientRequest(server.address(), common.mustCall((response) => {
15+
let body = '';
16+
response.setEncoding('utf8');
17+
response.on('data', (chunk) => {
18+
body += chunk;
19+
});
20+
21+
response.on('end', common.mustCall(() => {
22+
assert.strictEqual(body, 'hello world');
23+
server.close();
24+
}));
25+
}));
26+
27+
req.end();
28+
}));
29+
}
Lines changed: 14 additions & 0 deletions

0 commit comments

Comments
 (0)