@@ -7,6 +7,8 @@ const util = require('util');
77const internalUtil = require ( 'internal/util' ) ;
88const Buffer = require ( 'buffer' ) . Buffer ;
99const common = require ( '_http_common' ) ;
10+ const checkIsHttpToken = common . _checkIsHttpToken ;
11+ const checkInvalidHeaderChar = common . _checkInvalidHeaderChar ;
1012
1113const CRLF = common . CRLF ;
1214const trfrEncChunkExpression = common . chunkExpression ;
@@ -312,11 +314,11 @@ function _storeHeader(firstLine, headers) {
312314}
313315
314316function storeHeader ( self , state , field , value ) {
315- if ( ! common . _checkIsHttpToken ( field ) ) {
317+ if ( ! checkIsHttpToken ( field ) ) {
316318 throw new TypeError (
317319 'Header name must be a valid HTTP Token ["' + field + '"]' ) ;
318320 }
319- if ( common . _checkInvalidHeaderChar ( value ) === true ) {
321+ if ( checkInvalidHeaderChar ( value ) ) {
320322 debug ( 'Header "%s" contains invalid characters' , field ) ;
321323 throw new TypeError ( 'The header content contains invalid characters' ) ;
322324 }
@@ -350,14 +352,14 @@ function storeHeader(self, state, field, value) {
350352
351353
352354OutgoingMessage . prototype . setHeader = function setHeader ( name , value ) {
353- if ( ! common . _checkIsHttpToken ( name ) )
355+ if ( ! checkIsHttpToken ( name ) )
354356 throw new TypeError (
355357 'Header name must be a valid HTTP Token ["' + name + '"]' ) ;
356358 if ( value === undefined )
357359 throw new Error ( '"value" required in setHeader("' + name + '", value)' ) ;
358360 if ( this . _header )
359361 throw new Error ( 'Can\'t set headers after they are sent.' ) ;
360- if ( common . _checkInvalidHeaderChar ( value ) === true ) {
362+ if ( checkInvalidHeaderChar ( value ) ) {
361363 debug ( 'Header "%s" contains invalid characters' , name ) ;
362364 throw new TypeError ( 'The header content contains invalid characters' ) ;
363365 }
@@ -530,11 +532,11 @@ OutgoingMessage.prototype.addTrailers = function addTrailers(headers) {
530532 field = key ;
531533 value = headers [ key ] ;
532534 }
533- if ( ! common . _checkIsHttpToken ( field ) ) {
535+ if ( ! checkIsHttpToken ( field ) ) {
534536 throw new TypeError (
535537 'Trailer name must be a valid HTTP Token ["' + field + '"]' ) ;
536538 }
537- if ( common . _checkInvalidHeaderChar ( value ) === true ) {
539+ if ( checkInvalidHeaderChar ( value ) ) {
538540 debug ( 'Trailer "%s" contains invalid characters' , field ) ;
539541 throw new TypeError ( 'The trailer content contains invalid characters' ) ;
540542 }
0 commit comments