-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undocumented behavior for handling options of http.request #47624
Comments
I think this problem can be solved by adding validations in If it is ok, can I take this issue, thanks! |
I think we've also encountered this issue. It seems that in v20, if the URL’s I've created this reproducer: const https = require('https');
const url = require('url');
// Works in v18 fails in v20:
const opts = url.parse('https://postman-echo.com');
opts.path = '/get';
// Works in both versions:
// const opts = url.parse('https://postman-echo.com/get');
// Curiously, deleting either of these properties causes it to work in both versions:
// delete opts.href;
// delete opts.protocol;
console.log('node version:', process.version);
console.log('parsed url:', opts);
https.request(opts, response => {
console.log('status:', response.statusCode);
response.on('data', data => process.stdout.write(data));
}).end(); v20.1.0 output:
v18.16.0 output (expected)
|
@nodejs/http probably also @nodejs/url |
cc @Trott |
FWIW, setting |
I don't think it is likely that the
Unfortunately, the old I think the breaking change is related to how |
Thanks for the bisect @Trott. I'll take a look at it. |
Version
v20.0.0
Platform
Microsoft Windows NT 10.0.19045.0 x64
Subsystem
No response
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
Running using v19.9.0, it prints
What do you see instead?
Additional information
Before #47339,
url.isURL
checks if property href & origin exists, and it changed to check if property href & protocol exist now.So before that, the
Opt
above goes to the else branch ofClientRequest
, but now it goes to theelse if (isURL(input))
branch, in which it ignores thepath
property given and just glues pathname & search together.Reading the document, it says
url can be a string or a URL object
also never mentions anything about search or pathname.since I'm not providing a WHATWG URL object, I'm expecting to call this signature
http.request(options[, callback])
retaining mypath
property as what v19 and before do.The text was updated successfully, but these errors were encountered: