Skip to content

Commit e88df6e

Browse files
committed
fixup: cleanup
1 parent e259ee6 commit e88df6e

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

lib/_http_outgoing.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -876,19 +876,20 @@ 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;
881880

882-
if (len != null) {
883-
if (
884-
strictContentLength(msg) &&
885-
(fromEnd ? msg[kBytesWritten] + len !== msg._contentLength : msg[kBytesWritten] + len > msg._contentLength)
886-
) {
887-
throw new ERR_HTTP_CONTENT_LENGTH_MISMATCH(len + msg[kBytesWritten], msg._contentLength);
888-
}
881+
if (msg.strictContentLength) {
882+
len ??= typeof chunk === 'string' ? Buffer.byteLength(chunk, encoding) : chunk.byteLength;
889883
msg[kBytesWritten] += len;
890884
}
891885

886+
if (
887+
strictContentLength(msg) &&
888+
(fromEnd ? msg[kBytesWritten] + len !== msg._contentLength : msg[kBytesWritten] + len > msg._contentLength)
889+
) {
890+
throw new ERR_HTTP_CONTENT_LENGTH_MISMATCH(len + msg[kBytesWritten], msg._contentLength);
891+
}
892+
892893
if (!msg._header) {
893894
if (fromEnd) {
894895
len ??= typeof chunk === 'string' ? Buffer.byteLength(chunk, encoding) : chunk.byteLength;

0 commit comments

Comments
 (0)