Skip to content

Commit 20c7f2f

Browse files
committed
fixup: cleanup
1 parent e259ee6 commit 20c7f2f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/_http_outgoing.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -876,16 +876,18 @@ function write_(msg, chunk, encoding, callback, fromEnd) {
876876
return false;
877877
}
878878

879-
let len = msg.strictContentLength ?
880-
typeof chunk === 'string' ? Buffer.byteLength(chunk, encoding) : chunk.byteLength : null;
879+
let len;
880+
881+
if (msg.strictContentLength) {
882+
len ??= typeof chunk === 'string' ? Buffer.byteLength(chunk, encoding) : chunk.byteLength;
881883

882-
if (len != null) {
883884
if (
884885
strictContentLength(msg) &&
885886
(fromEnd ? msg[kBytesWritten] + len !== msg._contentLength : msg[kBytesWritten] + len > msg._contentLength)
886887
) {
887888
throw new ERR_HTTP_CONTENT_LENGTH_MISMATCH(len + msg[kBytesWritten], msg._contentLength);
888889
}
890+
889891
msg[kBytesWritten] += len;
890892
}
891893

0 commit comments

Comments
 (0)