Skip to content

Commit

Permalink
http: replace \r\n with CRLF
Browse files Browse the repository at this point in the history
  • Loading branch information
shfshanyue committed Sep 14, 2021
1 parent ed556c0 commit 8d297a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
7 changes: 4 additions & 3 deletions lib/_http_client.js
Expand Up @@ -51,6 +51,7 @@ const {
HTTPParser,
isLenient,
prepareError,
CRLF
} = require('_http_common');
const { OutgoingMessage } = require('_http_outgoing');
const Agent = require('_http_agent');
Expand Down Expand Up @@ -286,11 +287,11 @@ function ClientRequest(input, options, cb) {
throw new ERR_HTTP_HEADERS_SENT('render');
}

this._storeHeader(this.method + ' ' + this.path + ' HTTP/1.1\r\n',
this._storeHeader(this.method + ' ' + this.path + ' HTTP/1.1' + CRLF,
this[kOutHeaders]);
}
} else {
this._storeHeader(this.method + ' ' + this.path + ' HTTP/1.1\r\n',
this._storeHeader(this.method + ' ' + this.path + ' HTTP/1.1' + CRLF,
options.headers);
}

Expand Down Expand Up @@ -343,7 +344,7 @@ ClientRequest.prototype._implicitHeader = function _implicitHeader() {
if (this._header) {
throw new ERR_HTTP_HEADERS_SENT('render');
}
this._storeHeader(this.method + ' ' + this.path + ' HTTP/1.1\r\n',
this._storeHeader(this.method + ' ' + this.path + ' HTTP/1.1' + CRLF,
this[kOutHeaders]);
};

Expand Down
13 changes: 7 additions & 6 deletions lib/_http_outgoing.js
Expand Up @@ -45,9 +45,12 @@ const Stream = require('stream');
const internalUtil = require('internal/util');
const { kOutHeaders, utcDate, kNeedDrain } = require('internal/http');
const { Buffer } = require('buffer');
const common = require('_http_common');
const checkIsHttpToken = common._checkIsHttpToken;
const checkInvalidHeaderChar = common._checkInvalidHeaderChar;
const {
_checkIsHttpToken: checkIsHttpToken,
_checkInvalidHeaderChar: checkInvalidHeaderChar,
chunkExpression: RE_TE_CHUNKED,
CRLF
} = require('_http_common');
const {
defaultTriggerAsyncIdScope,
symbols: { async_id_symbol }
Expand Down Expand Up @@ -78,14 +81,12 @@ let debug = require('internal/util/debuglog').debuglog('http', (fn) => {
});

const HIGH_WATER_MARK = getDefaultHighWaterMark();
const { CRLF } = common;

const kCorked = Symbol('corked');

const nop = () => {};

const RE_CONN_CLOSE = /(?:^|\W)close(?:$|\W)/i;
const RE_TE_CHUNKED = common.chunkExpression;

// isCookieField performs a case-insensitive comparison of a provided string
// against the word "cookie." As of V8 6.6 this is faster than handrolling or
Expand Down Expand Up @@ -874,7 +875,7 @@ OutgoingMessage.prototype.end = function end(chunk, encoding, callback) {
const finish = onFinish.bind(undefined, this);

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 8d297a1

Please sign in to comment.