code: private static String readString(String fieldName, ByteBuf in) {
          int length = in.bytesBefore(MAX_FIELD_LENGTH + 1, (byte) 0);
          if (length < 0) {
              throw new DecoderException("field '" + fieldName + "' longer than " + MAX_FIELD_LENGTH + " chars");
          }
  
          String value = in.readSlice(length).toString(CharsetUtil.US_ASCII);
          in.skipBytes(1); // Skip the NUL.
  
          return value;
      }
docs: Reads a variable-length NUL-terminated string as defined in SOCKS4.