public static int decode ( WsByteBuffer headerBlock , int N ) { // if (!headerBlock.hasRemaining()) { // throw new HeaderFieldDecodingException("No length to decode"); // } int I = HpackUtils . getLSB ( headerBlock . get ( ) , N ) ; if ( I < HpackUtils . ipow ( 2 , N ) - 1 ) { return I ; } else { int M = 0 ; boolean done = false ; byte b ; while ( done == false ) { // If there are no further elements, this is an invalid HeaderBlock. // If this decode method is called, there should always be header // key value bytes after the integer representation. // if (!headerBlock.hasRemaining()) { // throw new HeaderFieldDecodingException(""); // } b = headerBlock . get ( ) ; I = I + ( ( b ) & 127 ) * HpackUtils . ipow ( 2 , M ) ; M = M + 7 ; if ( ( ( b & 128 ) == 128 ) == false ) done = true ; } return I ; } }
Decodes a provided byte array that was encoded using an N - bit prefix .