Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Agent = require('_http_agent');
const { Buffer } = require('buffer');
const { defaultTriggerAsyncIdScope } = require('internal/async_hooks');
const { URL, urlToOptions, searchParamsSymbol } = require('internal/url');
const { kOutHeaders, kNeedDrain } = require('internal/http');
const { kOutHeaders, kNeedDrain, kClosed } = require('internal/http');
const { connResetException, codes } = require('internal/errors');
const {
ERR_HTTP_HEADERS_SENT,
Expand Down Expand Up @@ -197,6 +197,8 @@ function ClientRequest(input, options, cb) {
}
this.insecureHTTPParser = insecureHTTPParser;

options.path = method === 'CONNECT' && options.path.charAt(0) === '/' ?
options.path.slice(1) : options.path;
this.path = options.path || '/';
if (cb) {
this.once('response', cb);
Expand Down Expand Up @@ -387,7 +389,7 @@ function _destroy(req, socket, err) {
if (err) {
req.emit('error', err);
}
req._closed = true;
req[kClosed] = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not ok, see discussion on #34313.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems strange, I can't remember changing this part of the file however I will revert the changes for now and create another PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git pull --rebase

req.emit('close');
}
}
Expand Down Expand Up @@ -430,7 +432,7 @@ function socketCloseListener() {
res.emit('error', connResetException('aborted'));
}
}
req._closed = true;
req[kClosed] = true;
req.emit('close');
if (!res.aborted && res.readable) {
res.on('end', function() {
Expand All @@ -450,7 +452,7 @@ function socketCloseListener() {
req.socket._hadError = true;
req.emit('error', connResetException('socket hang up'));
}
req._closed = true;
req[kClosed] = true;
req.emit('close');
}

Expand Down Expand Up @@ -555,7 +557,7 @@ function socketOnData(d) {

req.emit(eventName, res, socket, bodyHead);
req.destroyed = true;
req._closed = true;
req[kClosed] = true;
req.emit('close');
} else {
// Requested Upgrade or used CONNECT method, but have no handler.
Expand Down Expand Up @@ -727,7 +729,7 @@ function requestOnPrefinish() {
}

function emitFreeNT(req) {
req._closed = true;
req[kClosed] = true;
req.emit('close');
if (req.res) {
req.res.emit('close');
Expand Down