Skip to content

Commit a760d70

Browse files
mscdexevanlucas
authored andcommitted
http: simplify boolean checks
PR-URL: #6533 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent c8ad127 commit a760d70

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

lib/_http_outgoing.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ function _storeHeader(firstLine, headers) {
239239
this.upgrading = true;
240240

241241
// Date header
242-
if (this.sendDate === true && state.sentDateHeader === false) {
242+
if (this.sendDate && !state.sentDateHeader) {
243243
state.messageHeader += 'Date: ' + utcDate() + CRLF;
244244
}
245245

@@ -255,8 +255,7 @@ function _storeHeader(firstLine, headers) {
255255
// of creating security liabilities, so suppress the zero chunk and force
256256
// the connection to close.
257257
var statusCode = this.statusCode;
258-
if ((statusCode === 204 || statusCode === 304) &&
259-
this.chunkedEncoding === true) {
258+
if ((statusCode === 204 || statusCode === 304) && this.chunkedEncoding) {
260259
debug(statusCode + ' response should not use chunked encoding,' +
261260
' closing connection.');
262261
this.chunkedEncoding = false;
@@ -267,7 +266,7 @@ function _storeHeader(firstLine, headers) {
267266
if (this._removedHeader.connection) {
268267
this._last = true;
269268
this.shouldKeepAlive = false;
270-
} else if (state.sentConnectionHeader === false) {
269+
} else if (!state.sentConnectionHeader) {
271270
var shouldSendKeepAlive = this.shouldKeepAlive &&
272271
(state.sentContentLengthHeader ||
273272
this.useChunkedEncodingByDefault ||
@@ -280,8 +279,7 @@ function _storeHeader(firstLine, headers) {
280279
}
281280
}
282281

283-
if (state.sentContentLengthHeader === false &&
284-
state.sentTransferEncodingHeader === false) {
282+
if (!state.sentContentLengthHeader && !state.sentTransferEncodingHeader) {
285283
if (!this._hasBody) {
286284
// Make sure we don't end the 0\r\n\r\n at the end of the message.
287285
this.chunkedEncoding = false;

0 commit comments

Comments
 (0)