11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst http = require('http'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst server = http.createServer(common.mustCall(function(req, res) { 91cb0ef41Sopenharmony_ci res.writeHead(200); 101cb0ef41Sopenharmony_ci res.end('ok'); 111cb0ef41Sopenharmony_ci})); 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ciserver.listen(0, function() { 141cb0ef41Sopenharmony_ci const agent = new http.Agent(); 151cb0ef41Sopenharmony_ci agent.defaultPort = this.address().port; 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci // Options marked as explicitly undefined for readability 181cb0ef41Sopenharmony_ci // in this test, they should STAY undefined as options should not 191cb0ef41Sopenharmony_ci // be mutable / modified 201cb0ef41Sopenharmony_ci const options = { 211cb0ef41Sopenharmony_ci host: undefined, 221cb0ef41Sopenharmony_ci hostname: common.localhostIPv4, 231cb0ef41Sopenharmony_ci port: undefined, 241cb0ef41Sopenharmony_ci defaultPort: undefined, 251cb0ef41Sopenharmony_ci path: undefined, 261cb0ef41Sopenharmony_ci method: undefined, 271cb0ef41Sopenharmony_ci agent: agent 281cb0ef41Sopenharmony_ci }; 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci http.request(options, function(res) { 311cb0ef41Sopenharmony_ci res.resume(); 321cb0ef41Sopenharmony_ci server.close(); 331cb0ef41Sopenharmony_ci assert.strictEqual(options.host, undefined); 341cb0ef41Sopenharmony_ci assert.strictEqual(options.hostname, common.localhostIPv4); 351cb0ef41Sopenharmony_ci assert.strictEqual(options.port, undefined); 361cb0ef41Sopenharmony_ci assert.strictEqual(options.defaultPort, undefined); 371cb0ef41Sopenharmony_ci assert.strictEqual(options.path, undefined); 381cb0ef41Sopenharmony_ci assert.strictEqual(options.method, undefined); 391cb0ef41Sopenharmony_ci }).end(); 401cb0ef41Sopenharmony_ci}); 41