private Charset getCharset(final String charset) {

    String charsetLocal = charset;

    if (charsetLocal == null) {
      String contentType = getContentType();
      if (contentType != null) {
        charsetLocal = AsyncHttpProviderUtils.parseCharset(contentType);
      }
    }

    if (charsetLocal == null) {
      charsetLocal = Charsets.DEFAULT_CHARACTER_ENCODING;
    }

    return Charsets.lookupCharset(charsetLocal);
  }
  /**
   * @return the {@link CharsetDecoder} that should be used when converting content from binary to
   *     character
   */
  private CharsetDecoder getDecoder() {
    if (decoder == null) {
      decoder = decoders.get(encoding);

      if (decoder == null) {
        final Charset cs = Charsets.lookupCharset(encoding);
        decoder = cs.newDecoder();
        decoder.onMalformedInput(CodingErrorAction.REPLACE);
        decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);

        decoders.put(encoding, decoder);
      } else {
        decoder.reset();
      }
    }

    return decoder;
  }