code: public static Charset getCharset(CharSequence contentTypeValue, Charset defaultCharset) {
          if (contentTypeValue != null) {
              CharSequence charsetCharSequence = getCharsetAsSequence(contentTypeValue);
              if (charsetCharSequence != null) {
                  try {
                      return Charset.forName(charsetCharSequence.toString());
                  } catch (UnsupportedCharsetException ignored) {
                      return defaultCharset;
                  }
              } else {
                  return defaultCharset;
              }
          } else {
              return defaultCharset;
          }
      }
docs: Fetch charset from Content-Type header value.
  
  @param contentTypeValue Content-Type header value to parse
  @param defaultCharset   result to use in case of empty, incorrect or doesn't contain required part header value
  @return the charset from message's Content-Type header or {@code defaultCharset}
  if charset is not presented or unparsable