private void overlayValue ( HeaderElement elem ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Overlaying existing header: " + elem . getName ( ) ) ; } int next_index = this . lastCRLFBufferIndex ; int next_pos = this . lastCRLFPosition ; if ( null != elem . nextSequence && ! elem . nextSequence . wasAdded ( ) ) { next_index = elem . nextSequence . getLastCRLFBufferIndex ( ) ; next_pos = elem . nextSequence . getLastCRLFPosition ( ) ; } WsByteBuffer buffer = this . parseBuffers [ elem . getLastCRLFBufferIndex ( ) ] ; buffer . position ( elem . getLastCRLFPosition ( ) + ( elem . isLastCRLFaCR ( ) ? 2 : 1 ) ) ; if ( next_index == elem . getLastCRLFBufferIndex ( ) ) { // all in one buffer buffer . put ( elem . getKey ( ) . getMarshalledByteArray ( foundCompactHeader ( ) ) ) ; buffer . put ( elem . asRawBytes ( ) , elem . getOffset ( ) , elem . getValueLength ( ) ) ; } else { // header straddles buffers int index = elem . getLastCRLFBufferIndex ( ) ; index = overlayBytes ( elem . getKey ( ) . getMarshalledByteArray ( foundCompactHeader ( ) ) , 0 , - 1 , index ) ; index = overlayBytes ( elem . asRawBytes ( ) , elem . getOffset ( ) , elem . getValueLength ( ) , index ) ; buffer = this . parseBuffers [ index ] ; } // pad trailing whitespace if we need it int start = buffer . position ( ) ; if ( start < next_pos ) { scribbleWhiteSpace ( buffer , start , next_pos ) ; } }
Method to overlay the new header value onto the older value in the parse buffers .