@@ -45,9 +45,11 @@ const Stream = require('stream');
45
45
const internalUtil = require ( 'internal/util' ) ;
46
46
const { kOutHeaders, utcDate, kNeedDrain } = require ( 'internal/http' ) ;
47
47
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
+ } = require ( '_http_common' ) ;
51
53
const {
52
54
defaultTriggerAsyncIdScope,
53
55
symbols : { async_id_symbol }
@@ -78,14 +80,12 @@ let debug = require('internal/util/debuglog').debuglog('http', (fn) => {
78
80
} ) ;
79
81
80
82
const HIGH_WATER_MARK = getDefaultHighWaterMark ( ) ;
81
- const { CRLF } = common ;
82
83
83
84
const kCorked = Symbol ( 'corked' ) ;
84
85
85
86
const nop = ( ) => { } ;
86
87
87
88
const RE_CONN_CLOSE = / (?: ^ | \W ) c l o s e (?: $ | \W ) / i;
88
- const RE_TE_CHUNKED = common . chunkExpression ;
89
89
90
90
// isCookieField performs a case-insensitive comparison of a provided string
91
91
// against the word "cookie." As of V8 6.6 this is faster than handrolling or
@@ -417,7 +417,7 @@ function _storeHeader(firstLine, headers) {
417
417
418
418
// Date header
419
419
if ( this . sendDate && ! state . date ) {
420
- header += 'Date: ' + utcDate ( ) + CRLF ;
420
+ header += 'Date: ' + utcDate ( ) + '\r\n' ;
421
421
}
422
422
423
423
// Force the connection to close when the response is a 204 No Content or
@@ -447,14 +447,14 @@ function _storeHeader(firstLine, headers) {
447
447
const shouldSendKeepAlive = this . shouldKeepAlive &&
448
448
( state . contLen || this . useChunkedEncodingByDefault || this . agent ) ;
449
449
if ( shouldSendKeepAlive ) {
450
- header += 'Connection: keep-alive' + CRLF ;
450
+ header += 'Connection: keep-alive\r\n' ;
451
451
if ( this . _keepAliveTimeout && this . _defaultKeepAlive ) {
452
452
const timeoutSeconds = MathFloor ( this . _keepAliveTimeout / 1000 ) ;
453
- header += `Keep-Alive: timeout=${ timeoutSeconds } ${ CRLF } ` ;
453
+ header += `Keep-Alive: timeout=${ timeoutSeconds } \r\n ` ;
454
454
}
455
455
} else {
456
456
this . _last = true ;
457
- header += 'Connection: close' + CRLF ;
457
+ header += 'Connection: close\r\n' ;
458
458
}
459
459
}
460
460
@@ -467,9 +467,9 @@ function _storeHeader(firstLine, headers) {
467
467
} else if ( ! state . trailer &&
468
468
! this . _removedContLen &&
469
469
typeof this . _contentLength === 'number' ) {
470
- header += 'Content-Length: ' + this . _contentLength + CRLF ;
470
+ header += 'Content-Length: ' + this . _contentLength + '\r\n' ;
471
471
} else if ( ! this . _removedTE ) {
472
- header += 'Transfer-Encoding: chunked' + CRLF ;
472
+ header += 'Transfer-Encoding: chunked\r\n' ;
473
473
this . chunkedEncoding = true ;
474
474
} else {
475
475
// We should only be able to get here if both Content-Length and
@@ -487,7 +487,7 @@ function _storeHeader(firstLine, headers) {
487
487
throw new ERR_HTTP_TRAILER_INVALID ( ) ;
488
488
}
489
489
490
- this . _header = header + CRLF ;
490
+ this . _header = header + '\r\n' ;
491
491
this . _headerSent = false ;
492
492
493
493
// Wait until the first body chunk, or close(), is sent to flush,
@@ -514,7 +514,7 @@ function processHeader(self, state, key, value, validate) {
514
514
function storeHeader ( self , state , key , value , validate ) {
515
515
if ( validate )
516
516
validateHeaderValue ( key , value ) ;
517
- state . header += key + ': ' + value + CRLF ;
517
+ state . header += key + ': ' + value + '\r\n' ;
518
518
matchHeader ( self , state , key , value ) ;
519
519
}
520
520
@@ -694,7 +694,7 @@ ObjectDefineProperty(OutgoingMessage.prototype, 'writableNeedDrain', {
694
694
}
695
695
} ) ;
696
696
697
- const crlf_buf = Buffer . from ( CRLF ) ;
697
+ const crlf_buf = Buffer . from ( '\r\n' ) ;
698
698
OutgoingMessage . prototype . write = function write ( chunk , encoding , callback ) {
699
699
if ( typeof encoding === 'function' ) {
700
700
callback = encoding ;
@@ -818,7 +818,7 @@ OutgoingMessage.prototype.addTrailers = function addTrailers(headers) {
818
818
debug ( 'Trailer "%s" contains invalid characters' , field ) ;
819
819
throw new ERR_INVALID_CHAR ( 'trailer content' , field ) ;
820
820
}
821
- this . _trailer += field + ': ' + value + CRLF ;
821
+ this . _trailer += field + ': ' + value + '\r\n' ;
822
822
}
823
823
} ;
824
824
0 commit comments