Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http: there is no corked property of stream #18325

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
11 changes: 8 additions & 3 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const errors = require('internal/errors');
const { CRLF, debug } = common;
const { utcDate } = internalHttp;

const kIsCorked = Symbol('isCorked');

var RE_FIELDS =
/^(?:Connection|Transfer-Encoding|Content-Length|Date|Expect|Trailer|Upgrade)$/i;
var RE_CONN_VALUES = /(?:^|\W)close|upgrade(?:$|\W)/ig;
Expand Down Expand Up @@ -99,6 +101,7 @@ function OutgoingMessage() {

this.finished = false;
this._headerSent = false;
this[kIsCorked] = false;

this.socket = null;
this.connection = null;
Expand Down Expand Up @@ -658,9 +661,10 @@ function write_(msg, chunk, encoding, callback, fromEnd) {
// signal the user to keep writing.
if (chunk.length === 0) return true;

if (!fromEnd && msg.connection && !msg.connection.corked) {
if (!fromEnd && msg.connection && !msg[kIsCorked]) {
msg.connection.cork();
process.nextTick(connectionCorkNT, msg.connection);
msg[kIsCorked] = true;
process.nextTick(connectionCorkNT, msg, msg.connection);
}

var len, ret;
Expand Down Expand Up @@ -689,7 +693,8 @@ function writeAfterEndNT(err, callback) {
}


function connectionCorkNT(conn) {
function connectionCorkNT(msg, conn) {
msg[kIsCorked] = false;
conn.uncork();
}

Expand Down