node/test/parallel/test-http-request-arguments.js
Sam Ruby f9b739ebbc http: allow url and options to be passed to http*.request and http*.get
Fixes: https://github.com/nodejs/node/issues/20795
PR-URL: https://github.com/nodejs/node/pull/21616
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Ron Korving <ron@ronkorving.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-07-13 14:09:39 +01:00

29 lines
682 B
JavaScript

'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
// 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();
})
);
})
);
}