-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
url: allow extension of user provided URL objects
PR-URL: #46989 Fixes: #46981 Reviewed-By: Yagiz Nizipli <[email protected]>
- Loading branch information
Showing
3 changed files
with
51 additions
and
13 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
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,27 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('node:assert'); | ||
const http = require('node:http'); | ||
|
||
const headers = { foo: 'Bar' }; | ||
const server = http.createServer(common.mustCall((req, res) => { | ||
assert.strictEqual(req.url, '/ping?q=term'); | ||
assert.strictEqual(req.headers?.foo, headers.foo); | ||
req.resume(); | ||
req.on('end', () => { | ||
res.writeHead(200); | ||
res.end('pong'); | ||
}); | ||
})); | ||
|
||
server.listen(0, common.localhostIPv4, () => { | ||
const { address, port } = server.address(); | ||
const url = new URL(`http://${address}:${port}/ping?q=term`); | ||
url.headers = headers; | ||
const clientReq = http.request(url); | ||
clientReq.on('close', common.mustCall(() => { | ||
server.close(); | ||
})); | ||
clientReq.end(); | ||
}); |