Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Sep 19, 2023
1 parent 37d005a commit 289444e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
15 changes: 6 additions & 9 deletions lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,11 @@ function ClientRequest(input, options, cb) {
const defaultPort = options.defaultPort ||
(this.agent && this.agent.defaultPort);

const port = options.port = options.port || defaultPort || 80;
const host = options.host = validateHost(options.hostname, 'hostname') ||
validateHost(options.host, 'host') || 'localhost';
const optsWithoutSignal = { __proto__: null, ...options };

const port = optsWithoutSignal.port = options.port || defaultPort || 80;
const host = optsWithoutSignal.host = validateHost(options.hostname, 'hostname') ||
validateHost(options.host, 'host') || 'localhost';

const setHost = (options.setHost === undefined || Boolean(options.setHost));

Expand All @@ -200,6 +202,7 @@ function ClientRequest(input, options, cb) {
const signal = options.signal;
if (signal) {
addAbortSignal(signal, this);
delete optsWithoutSignal.signal;
}
let method = options.method;
const methodIsString = (typeof method === 'string');
Expand Down Expand Up @@ -326,12 +329,6 @@ function ClientRequest(input, options, cb) {

this[kUniqueHeaders] = parseUniqueHeadersOption(options.uniqueHeaders);

let optsWithoutSignal = options;
if (optsWithoutSignal.signal) {
optsWithoutSignal = ObjectAssign({}, options);
delete optsWithoutSignal.signal;
}

// initiate connection
if (this.agent) {
this.agent.addRequest(this, optsWithoutSignal);
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-http-client-input-function.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
const common = require('../common');
const http = require('http');
const assert = require('assert');
const ClientRequest = require('http').ClientRequest;

{
const server = http.createServer(common.mustCall((req, res) => {
res.writeHead(200);
res.end('hello world');
})).listen(80, '127.0.0.1');

const req = new ClientRequest(common.mustCall((response) => {
const req = new http.ClientRequest(common.mustCall((response) => {
let body = '';
response.setEncoding('utf8');
response.on('data', (chunk) => {
Expand Down

0 comments on commit 289444e

Please sign in to comment.