url: keep urlToHttpOptions() result in fast mode

urlToHttpOptions() built its result with `__proto__: null` ahead of a
spread, which makes V8 create the object in dictionary mode. Every
http.request() and https.request() called with a string or URL goes
through it, and ClientRequest immediately copies the result, so both
the property stores and the copy took the slow path.

Use `__proto__: kEmptyObject` instead, as ClientRequest already does
for its option copies. The object stays in fast mode and still
inherits nothing.

Signed-off-by: Yaroslav Chuhai <yaroslavchuhai@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67683
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Yaroslav Chuhai authored and Antoine du Hamel committed 2026-11-24 09:51:48 +01:00
1 parent 76b0d6c519
commit dbeb6e49bb
1 file changed
+1 -1
+1 -1
View File
@@ -1480,7 +1480,7 @@ function urlToHttpOptions(url) {
validateObject(url, 'url', kValidateObjectAllowObjects);
const { hostname, pathname, port, username, password, search } = url;
const options = {
__proto__: null,
__proto__: kEmptyObject,
// Only spread own enumerable properties for genuine WHATWG URL instances so
// that a URL object can still be extended with additional request options
// (e.g. `url.headers = ...`). Arbitrary duck-typed objects accepted by