private boolean parseHeaderName ( WsByteBuffer buff ) throws MalformedMessageException { // if we're just starting, then skip leading white space characters // otherwise ignore them (i.e we might be in the middle of // "Mozilla/5.0 (Win" if ( null == this . parsedToken ) { if ( ! skipWhiteSpace ( buff ) ) { return false ; } } int start = findCurrentBufferPosition ( buff ) ; int cachestart = this . bytePosition ; TokenCodes rc = findHeaderLength ( buff ) ; if ( TokenCodes . TOKEN_RC_MOREDATA . equals ( rc ) ) { // ran out of data saveParsedToken ( buff , start , false , LOG_FULL ) ; return false ; } // could be in one single bytecache, otherwise we have to extract from // buffer byte [ ] data ; int length = this . parsedTokenLength ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "length=" + length + " pos=" + this . bytePosition + ", cachestart=" + cachestart + ", start=" + start + ", trailingWhitespace=" + this . foundTrailingWhitespace ) ; } //PI13987 - Added the first argument to the if statement if ( ! this . foundTrailingWhitespace && null == this . parsedToken && length < this . bytePosition ) { // it's all in the bytecache if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { //PI13987 - Modified the message being printed as we now print the same thing above Tr . debug ( tc , "Using bytecache" ) ; } data = this . byteCache ; start = cachestart ; } else { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { //PI13987 Tr . debug ( tc , "Using bytebuffer" ) ; } saveParsedToken ( buff , start , true , LOG_FULL ) ; data = this . parsedToken ; start = 0 ; length = data . length ; } // otherwise we found the entire length of the name this . currentElem = getElement ( findKey ( data , start , length ) ) ; // Reset all the global variables once HeaderElement has been instantiated if ( HeaderStorage . NOTSET != this . headerChangeLimit ) { this . currentElem . updateLastCRLFInfo ( this . lastCRLFBufferIndex , this . lastCRLFPosition , this . lastCRLFisCR ) ; } this . stateOfParsing = PARSING_VALUE ; this . parsedToken = null ; this . parsedTokenLength = 0 ; this . foundTrailingWhitespace = false ; //PI13987 return true ; }
Utility method to parse the header name from the input buffer .