Skip to content

Commit 8d297a1

Browse files
committed
http: replace \r\n with CRLF
1 parent ed556c0 commit 8d297a1

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

lib/_http_client.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const {
5151
HTTPParser,
5252
isLenient,
5353
prepareError,
54+
CRLF
5455
} = require('_http_common');
5556
const { OutgoingMessage } = require('_http_outgoing');
5657
const Agent = require('_http_agent');
@@ -286,11 +287,11 @@ function ClientRequest(input, options, cb) {
286287
throw new ERR_HTTP_HEADERS_SENT('render');
287288
}
288289

289-
this._storeHeader(this.method + ' ' + this.path + ' HTTP/1.1\r\n',
290+
this._storeHeader(this.method + ' ' + this.path + ' HTTP/1.1' + CRLF,
290291
this[kOutHeaders]);
291292
}
292293
} else {
293-
this._storeHeader(this.method + ' ' + this.path + ' HTTP/1.1\r\n',
294+
this._storeHeader(this.method + ' ' + this.path + ' HTTP/1.1' + CRLF,
294295
options.headers);
295296
}
296297

@@ -343,7 +344,7 @@ ClientRequest.prototype._implicitHeader = function _implicitHeader() {
343344
if (this._header) {
344345
throw new ERR_HTTP_HEADERS_SENT('render');
345346
}
346-
this._storeHeader(this.method + ' ' + this.path + ' HTTP/1.1\r\n',
347+
this._storeHeader(this.method + ' ' + this.path + ' HTTP/1.1' + CRLF,
347348
this[kOutHeaders]);
348349
};
349350

lib/_http_outgoing.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,12 @@ const Stream = require('stream');
4545
const internalUtil = require('internal/util');
4646
const { kOutHeaders, utcDate, kNeedDrain } = require('internal/http');
4747
const { Buffer } = require('buffer');
48-
const common = require('_http_common');
49-
const checkIsHttpToken = common._checkIsHttpToken;
50-
const checkInvalidHeaderChar = common._checkInvalidHeaderChar;
48+
const {
49+
_checkIsHttpToken: checkIsHttpToken,
50+
_checkInvalidHeaderChar: checkInvalidHeaderChar,
51+
chunkExpression: RE_TE_CHUNKED,
52+
CRLF
53+
} = require('_http_common');
5154
const {
5255
defaultTriggerAsyncIdScope,
5356
symbols: { async_id_symbol }
@@ -78,14 +81,12 @@ let debug = require('internal/util/debuglog').debuglog('http', (fn) => {
7881
});
7982

8083
const HIGH_WATER_MARK = getDefaultHighWaterMark();
81-
const { CRLF } = common;
8284

8385
const kCorked = Symbol('corked');
8486

8587
const nop = () => {};
8688

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

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

876877
if (this._hasBody && this.chunkedEncoding) {
877-
this._send('0\r\n' + this._trailer + '\r\n', 'latin1', finish);
878+
this._send('0' + CRLF + this._trailer + CRLF, 'latin1', finish);
878879
} else {
879880
// Force a flush, HACK.
880881
this._send('', 'latin1', finish);

0 commit comments

Comments
 (0)