private static String decodeFragment ( WsByteBuffer buffer ) throws CompressionException { String decodedResult = null ; try { byte currentByte = buffer . get ( ) ; //Reset back position to decode the integer length of this segment. buffer . position ( buffer . position ( ) - 1 ) ; boolean huffman = ( HpackUtils . getBit ( currentByte , 7 ) == 1 ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Decoding using huffman encoding: " + huffman ) ; } //HUFFMAN and NOHUFFMAN ByteFormatTypes have the same //integer decoding bits (N=7). Therefore, either enum value //is valid for the integer representation decoder. int fragmentLength = IntegerRepresentation . decode ( buffer , ByteFormatType . HUFFMAN ) ; byte [ ] bytes = new byte [ fragmentLength ] ; //Transfer bytes from the buffer into byte array. buffer . get ( bytes ) ; if ( huffman && bytes . length > 0 ) { HuffmanDecoder decoder = new HuffmanDecoder ( ) ; bytes = decoder . convertHuffmanToAscii ( bytes ) ; } decodedResult = new String ( bytes , Charset . forName ( HpackConstants . HPACK_CHAR_SET ) ) ; } catch ( Exception e ) { throw new CompressionException ( "Received an invalid header block fragment" ) ; } return decodedResult ; }
Decode a Fragment of the Header . Fragment in this case refers to the bytes that represent the integer length and octets length of either the Name or Value of a Header . For instance in the case of the Name the fragment is