code: public static String parseCharset(Map<String, String> headers, String defaultCharset) {
          String contentType = headers.get(HTTP.CONTENT_TYPE);
          if (contentType != null) {
              String[] params = contentType.split(";");
              for (int i = 1; i < params.length; i++) {
                  String[] pair = params[i].trim().split("=");
                  if (pair.length == 2) {
                      if (pair[0].equals("charset")) {
                          return pair[1];
                      }
                  }
              }
          }
  
          return defaultCharset;
      }
docs: Retrieve a charset from headers
  
  @param headers        An {@link java.util.Map} of headers
  @param defaultCharset Charset to return if none can be found
  @return Returns the charset specified in the Content-Type of this header,
  or the defaultCharset if none can be found.