1'use strict';
2
3const common = require('../common');
4const assert = require('assert');
5const http = require('http');
6
7
8const server = http.createServer(common.mustCall(function(req, res) {
9  res.writeHead(200);
10  res.end('ok');
11}));
12
13server.listen(0, function() {
14  const agent = new http.Agent();
15  agent.defaultPort = this.address().port;
16
17  // Options marked as explicitly undefined for readability
18  // in this test, they should STAY undefined as options should not
19  // be mutable / modified
20  const options = {
21    host: undefined,
22    hostname: common.localhostIPv4,
23    port: undefined,
24    defaultPort: undefined,
25    path: undefined,
26    method: undefined,
27    agent: agent
28  };
29
30  http.request(options, function(res) {
31    res.resume();
32    server.close();
33    assert.strictEqual(options.host, undefined);
34    assert.strictEqual(options.hostname, common.localhostIPv4);
35    assert.strictEqual(options.port, undefined);
36    assert.strictEqual(options.defaultPort, undefined);
37    assert.strictEqual(options.path, undefined);
38    assert.strictEqual(options.method, undefined);
39  }).end();
40});
41