code: static ByteBuf encodeRemainingLength(int value) throws CorruptedFrameException {
          if (value > MAX_LENGTH_LIMIT || value < 0) {
              throw new CorruptedFrameException("Value should in range 0.." + MAX_LENGTH_LIMIT + " found " + value);
          }
  
          ByteBuf encoded = Unpooled.buffer(4);
          byte digit;
          do {
              digit = (byte) (value % 128);
              value = value / 128;
              // if there are more digits to encode, set the top bit of this digit
              if (value > 0) {
                  digit = (byte) (digit | 0x80);
              }
              encoded.writeByte(digit);
          } while (value > 0);
          return encoded;
      }
docs: Encode the value in the format defined in specification as variable length
  array.
  
  @throws IllegalArgumentException if the value is not in the specification bounds
  [0..268435455].