-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: do not override user-provided options object
PR-URL: #33633 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
1 parent
0ac070c
commit 9062d30
Showing
3 changed files
with
49 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const http = require('http'); | ||
const assert = require('assert'); | ||
|
||
{ | ||
const server = http.createServer(common.mustCall((req, res) => { | ||
res.writeHead(200); | ||
res.end('hello world'); | ||
})).listen(0, '127.0.0.1'); | ||
|
||
server.on('listening', common.mustCall(() => { | ||
const req = new http.ClientRequest(server.address(), common.mustCall((response) => { | ||
let body = ''; | ||
response.setEncoding('utf8'); | ||
response.on('data', (chunk) => { | ||
body += chunk; | ||
}); | ||
|
||
response.on('end', common.mustCall(() => { | ||
assert.strictEqual(body, 'hello world'); | ||
server.close(); | ||
})); | ||
})); | ||
|
||
req.end(); | ||
})); | ||
} |
14 changes: 14 additions & 0 deletions
14
test/parallel/test-http-client-insecure-http-parser-error.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
const ClientRequest = require('http').ClientRequest; | ||
|
||
{ | ||
assert.throws(() => { | ||
new ClientRequest({ insecureHTTPParser: 'wrongValue' }); | ||
}, { | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
message: /insecureHTTPParser/ | ||
}, 'http request should throw when passing invalid insecureHTTPParser'); | ||
} |