Skip to content

Commit

Permalink
http: simplify boolean checks
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
mscdex authored and evanlucas committed Jan 4, 2017
1 parent c8ad127 commit a760d70
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ function _storeHeader(firstLine, headers) {
this.upgrading = true;

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

Expand All @@ -255,8 +255,7 @@ function _storeHeader(firstLine, headers) {
// of creating security liabilities, so suppress the zero chunk and force
// the connection to close.
var statusCode = this.statusCode;
if ((statusCode === 204 || statusCode === 304) &&
this.chunkedEncoding === true) {
if ((statusCode === 204 || statusCode === 304) && this.chunkedEncoding) {
debug(statusCode + ' response should not use chunked encoding,' +
' closing connection.');
this.chunkedEncoding = false;
Expand All @@ -267,7 +266,7 @@ function _storeHeader(firstLine, headers) {
if (this._removedHeader.connection) {
this._last = true;
this.shouldKeepAlive = false;
} else if (state.sentConnectionHeader === false) {
} else if (!state.sentConnectionHeader) {
var shouldSendKeepAlive = this.shouldKeepAlive &&
(state.sentContentLengthHeader ||
this.useChunkedEncodingByDefault ||
Expand All @@ -280,8 +279,7 @@ function _storeHeader(firstLine, headers) {
}
}

if (state.sentContentLengthHeader === false &&
state.sentTransferEncodingHeader === false) {
if (!state.sentContentLengthHeader && !state.sentTransferEncodingHeader) {
if (!this._hasBody) {
// Make sure we don't end the 0\r\n\r\n at the end of the message.
this.chunkedEncoding = false;
Expand Down

0 comments on commit a760d70

Please sign in to comment.