Skip to content

Commit

Permalink
http: use CRLF conistently in _http_outgoing.js
Browse files Browse the repository at this point in the history
PR-URL: #37851
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
danbev authored and jasnell committed Mar 22, 2021
1 parent 3b3838d commit f4d3d12
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,14 +502,14 @@ function _storeHeader(firstLine, headers) {
const shouldSendKeepAlive = this.shouldKeepAlive &&
(state.contLen || this.useChunkedEncodingByDefault || this.agent);
if (shouldSendKeepAlive) {
header += 'Connection: keep-alive\r\n';
header += 'Connection: keep-alive' + CRLF;
if (this._keepAliveTimeout && this._defaultKeepAlive) {
const timeoutSeconds = MathFloor(this._keepAliveTimeout / 1000);
header += `Keep-Alive: timeout=${timeoutSeconds}\r\n`;
header += `Keep-Alive: timeout=${timeoutSeconds}${CRLF}`;
}
} else {
this._last = true;
header += 'Connection: close\r\n';
header += 'Connection: close' + CRLF;
}
}

Expand All @@ -525,7 +525,7 @@ function _storeHeader(firstLine, headers) {
typeof this._contentLength === 'number') {
header += 'Content-Length: ' + this._contentLength + CRLF;
} else if (!this._removedTE) {
header += 'Transfer-Encoding: chunked\r\n';
header += 'Transfer-Encoding: chunked' + CRLF;
this.chunkedEncoding = true;
} else {
// We should only be able to get here if both Content-Length and
Expand Down Expand Up @@ -740,7 +740,7 @@ ObjectDefineProperty(OutgoingMessage.prototype, 'headersSent', {
get: function() { return !!this._header; }
});

const crlf_buf = Buffer.from('\r\n');
const crlf_buf = Buffer.from(CRLF);
OutgoingMessage.prototype.write = function write(chunk, encoding, callback) {
if (typeof encoding === 'function') {
callback = encoding;
Expand Down Expand Up @@ -903,7 +903,7 @@ OutgoingMessage.prototype.end = function end(chunk, encoding, callback) {
state.finalCalled = true;

if (this._hasBody && this.chunkedEncoding) {
this._send('0\r\n' + this._trailer + '\r\n', 'latin1', finish);
this._send('0' + CRLF + this._trailer + CRLF, 'latin1', finish);
} else {
// Force a flush, HACK.
this._send('', 'latin1', finish);
Expand Down

0 comments on commit f4d3d12

Please sign in to comment.