@@ -9,6 +9,8 @@ const Buffer = require('buffer').Buffer;
9
9
const common = require ( '_http_common' ) ;
10
10
const checkIsHttpToken = common . _checkIsHttpToken ;
11
11
const checkInvalidHeaderChar = common . _checkInvalidHeaderChar ;
12
+ const outHeadersKey = require ( 'internal/http' ) . outHeadersKey ;
13
+ const StorageObject = require ( 'internal/querystring' ) . StorageObject ;
12
14
13
15
const CRLF = common . CRLF ;
14
16
const debug = common . debug ;
@@ -74,7 +76,7 @@ function OutgoingMessage() {
74
76
this . socket = null ;
75
77
this . connection = null ;
76
78
this . _header = null ;
77
- this . _headers = null ;
79
+ this [ outHeadersKey ] = null ;
78
80
79
81
this . _onPendingData = null ;
80
82
}
@@ -201,7 +203,7 @@ function _storeHeader(firstLine, headers) {
201
203
var value ;
202
204
var i ;
203
205
var j ;
204
- if ( headers === this . _headers ) {
206
+ if ( headers === this [ outHeadersKey ] ) {
205
207
for ( key in headers ) {
206
208
var entry = headers [ key ] ;
207
209
field = entry [ 0 ] ;
@@ -393,11 +395,11 @@ function validateHeader(msg, name, value) {
393
395
OutgoingMessage . prototype . setHeader = function setHeader ( name , value ) {
394
396
validateHeader ( this , name , value ) ;
395
397
396
- if ( ! this . _headers )
397
- this . _headers = { } ;
398
+ if ( ! this [ outHeadersKey ] )
399
+ this [ outHeadersKey ] = { } ;
398
400
399
401
const key = name . toLowerCase ( ) ;
400
- this . _headers [ key ] = [ name , value ] ;
402
+ this [ outHeadersKey ] [ key ] = [ name , value ] ;
401
403
402
404
switch ( key . length ) {
403
405
case 10 :
@@ -421,9 +423,9 @@ OutgoingMessage.prototype.getHeader = function getHeader(name) {
421
423
throw new TypeError ( '"name" argument must be a string' ) ;
422
424
}
423
425
424
- if ( ! this . _headers ) return ;
426
+ if ( ! this [ outHeadersKey ] ) return ;
425
427
426
- var entry = this . _headers [ name . toLowerCase ( ) ] ;
428
+ var entry = this [ outHeadersKey ] [ name . toLowerCase ( ) ] ;
427
429
if ( ! entry )
428
430
return ;
429
431
return entry [ 1 ] ;
@@ -432,13 +434,13 @@ OutgoingMessage.prototype.getHeader = function getHeader(name) {
432
434
433
435
// Returns an array of the names of the current outgoing headers.
434
436
OutgoingMessage . prototype . getHeaderNames = function getHeaderNames ( ) {
435
- return ( this . _headers ? Object . keys ( this . _headers ) : [ ] ) ;
437
+ return ( this [ outHeadersKey ] ? Object . keys ( this [ outHeadersKey ] ) : [ ] ) ;
436
438
} ;
437
439
438
440
439
441
// Returns a shallow copy of the current outgoing headers.
440
442
OutgoingMessage . prototype . getHeaders = function getHeaders ( ) {
441
- const headers = this . _headers ;
443
+ const headers = this [ outHeadersKey ] ;
442
444
const ret = new OutgoingHeaders ( ) ;
443
445
if ( headers ) {
444
446
const keys = Object . keys ( headers ) ;
@@ -457,7 +459,7 @@ OutgoingMessage.prototype.hasHeader = function hasHeader(name) {
457
459
throw new TypeError ( '"name" argument must be a string' ) ;
458
460
}
459
461
460
- return ! ! ( this . _headers && this . _headers [ name . toLowerCase ( ) ] ) ;
462
+ return ! ! ( this [ outHeadersKey ] && this [ outHeadersKey ] [ name . toLowerCase ( ) ] ) ;
461
463
} ;
462
464
463
465
@@ -491,8 +493,8 @@ OutgoingMessage.prototype.removeHeader = function removeHeader(name) {
491
493
break ;
492
494
}
493
495
494
- if ( this . _headers ) {
495
- delete this . _headers [ key ] ;
496
+ if ( this [ outHeadersKey ] ) {
497
+ delete this [ outHeadersKey ] [ key ] ;
496
498
}
497
499
} ;
498
500
0 commit comments