-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
http: allow url and options to be passed to http.request #21616
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const http = require('http'); | ||
|
||
// test providing both a url and options, with the options partially | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extreme nit: start comments with uppercase ... (we're trying to be more consistent throughout on this)... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And we also try to add a period to the comment end) |
||
// replacing address and port portions of the URL provided | ||
{ | ||
const server = http.createServer( | ||
common.mustCall((req, res) => { | ||
assert.strictEqual(req.url, '/testpath'); | ||
res.end(); | ||
server.close(); | ||
}) | ||
); | ||
server.listen( | ||
0, | ||
common.mustCall(() => { | ||
http.get( | ||
'http://example.com/testpath', | ||
{ hostname: 'localhost', port: server.address().port }, | ||
common.mustCall((res) => { | ||
res.resume(); | ||
}) | ||
); | ||
}) | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
including an example here would likely be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do have an example in the test case, but it is a bit contrived. While I am struggling to find a clear real world use case, I feel that the documentation would be incomplete without at least mentioning what would happen in the (however unlikely event) that there is overlap in the url and options.