Skip to content

Commit 19bddc6

Browse files
committed
http: cleanup cork logic
1 parent ca2f874 commit 19bddc6

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/_http_outgoing.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ ObjectDefineProperty(OutgoingMessage.prototype, 'writableHighWaterMark', {
211211
ObjectDefineProperty(OutgoingMessage.prototype, 'writableCorked', {
212212
__proto__: null,
213213
get() {
214-
return this[kCorked];
214+
return this[kSocket] ? this[kSocket].writableCorked : this[kCorked];
215215
},
216216
});
217217

@@ -1000,9 +1000,9 @@ function write_(msg, chunk, encoding, callback, fromEnd) {
10001000
}
10011001
}
10021002

1003-
if (!fromEnd && msg.socket && !msg.socket.writableCorked) {
1004-
msg.socket.cork();
1005-
process.nextTick(connectionCorkNT, msg.socket);
1003+
if (!fromEnd && !msg.writableCorked) {
1004+
msg.cork();
1005+
process.nextTick(connectionUncorkNT, msg);
10061006
}
10071007

10081008
let ret;
@@ -1027,8 +1027,8 @@ function write_(msg, chunk, encoding, callback, fromEnd) {
10271027
}
10281028

10291029

1030-
function connectionCorkNT(conn) {
1031-
conn.uncork();
1030+
function connectionUncorkNT(msg) {
1031+
msg.uncork();
10321032
}
10331033

10341034
OutgoingMessage.prototype.addTrailers = function addTrailers(headers) {
@@ -1143,9 +1143,9 @@ OutgoingMessage.prototype.end = function end(chunk, encoding, callback) {
11431143
// Fully uncork connection on end().
11441144
this[kSocket]._writableState.corked = 1;
11451145
this[kSocket].uncork();
1146+
} else {
1147+
this[kCorked] = 0;
11461148
}
1147-
this[kCorked] = 1;
1148-
this.uncork();
11491149

11501150
this.finished = true;
11511151

0 commit comments

Comments
 (0)