private void encodeLiteral ( ByteBuf out , CharSequence name , CharSequence value , IndexType indexType , int nameIndex ) { boolean nameIndexValid = nameIndex != - 1 ; switch ( indexType ) { case INCREMENTAL : encodeInteger ( out , 0x40 , 6 , nameIndexValid ? nameIndex : 0 ) ; break ; case NONE : encodeInteger ( out , 0x00 , 4 , nameIndexValid ? nameIndex : 0 ) ; break ; case NEVER : encodeInteger ( out , 0x10 , 4 , nameIndexValid ? nameIndex : 0 ) ; break ; default : throw new Error ( "should not reach here" ) ; } if ( ! nameIndexValid ) { encodeStringLiteral ( out , name ) ; } encodeStringLiteral ( out , value ) ; }
Encode literal header field according to Section 6 . 2 .