@@ -7,6 +7,8 @@ const util = require('util');
7
7
const internalUtil = require ( 'internal/util' ) ;
8
8
const Buffer = require ( 'buffer' ) . Buffer ;
9
9
const common = require ( '_http_common' ) ;
10
+ const checkIsHttpToken = common . _checkIsHttpToken ;
11
+ const checkInvalidHeaderChar = common . _checkInvalidHeaderChar ;
10
12
11
13
const CRLF = common . CRLF ;
12
14
const trfrEncChunkExpression = common . chunkExpression ;
@@ -312,11 +314,11 @@ function _storeHeader(firstLine, headers) {
312
314
}
313
315
314
316
function storeHeader ( self , state , field , value ) {
315
- if ( ! common . _checkIsHttpToken ( field ) ) {
317
+ if ( ! checkIsHttpToken ( field ) ) {
316
318
throw new TypeError (
317
319
'Header name must be a valid HTTP Token ["' + field + '"]' ) ;
318
320
}
319
- if ( common . _checkInvalidHeaderChar ( value ) === true ) {
321
+ if ( checkInvalidHeaderChar ( value ) ) {
320
322
debug ( 'Header "%s" contains invalid characters' , field ) ;
321
323
throw new TypeError ( 'The header content contains invalid characters' ) ;
322
324
}
@@ -350,14 +352,14 @@ function storeHeader(self, state, field, value) {
350
352
351
353
352
354
OutgoingMessage . prototype . setHeader = function setHeader ( name , value ) {
353
- if ( ! common . _checkIsHttpToken ( name ) )
355
+ if ( ! checkIsHttpToken ( name ) )
354
356
throw new TypeError (
355
357
'Header name must be a valid HTTP Token ["' + name + '"]' ) ;
356
358
if ( value === undefined )
357
359
throw new Error ( '"value" required in setHeader("' + name + '", value)' ) ;
358
360
if ( this . _header )
359
361
throw new Error ( 'Can\'t set headers after they are sent.' ) ;
360
- if ( common . _checkInvalidHeaderChar ( value ) === true ) {
362
+ if ( checkInvalidHeaderChar ( value ) ) {
361
363
debug ( 'Header "%s" contains invalid characters' , name ) ;
362
364
throw new TypeError ( 'The header content contains invalid characters' ) ;
363
365
}
@@ -530,11 +532,11 @@ OutgoingMessage.prototype.addTrailers = function addTrailers(headers) {
530
532
field = key ;
531
533
value = headers [ key ] ;
532
534
}
533
- if ( ! common . _checkIsHttpToken ( field ) ) {
535
+ if ( ! checkIsHttpToken ( field ) ) {
534
536
throw new TypeError (
535
537
'Trailer name must be a valid HTTP Token ["' + field + '"]' ) ;
536
538
}
537
- if ( common . _checkInvalidHeaderChar ( value ) === true ) {
539
+ if ( checkInvalidHeaderChar ( value ) ) {
538
540
debug ( 'Trailer "%s" contains invalid characters' , field ) ;
539
541
throw new TypeError ( 'The trailer content contains invalid characters' ) ;
540
542
}
0 commit comments