private static Charset getCharset(URLConnection connection) throws IOException {
      String contentType = connection.getContentType();
      if (contentType != null && !contentType.isEmpty()) {
        Matcher m = CHARSET_PATTERN.matcher(contentType);
        if (m.find()) {
          try {
            return Charset.forName(StringUtil.unquoteString(m.group(1)));
          }
          catch (IllegalArgumentException e) {
            throw new IOException("Unknown charset: " + contentType, e);
          }
        }
      }
      return StandardCharsets.UTF_8;
    }
private static Charset getCharset(URLConnection connection)