Java 类org.apache.http.message.HeaderValueParser 实例源码

项目:rockscript    文件:ClientResponse.java   
public String getContentTypeCharset(String defaultCharset) {
  List<String> values = getHeader(Http.Headers.CONTENT_TYPE);
  if (values!=null) {
    for (String value: values) {
      HeaderElement[] headerElements = BasicHeaderValueParser.parseElements(value, (HeaderValueParser) null);
      if (headerElements!=null && headerElements.length>0) {
        NameValuePair charsetPair = headerElements[0].getParameterByName("charset");
        if (charsetPair!=null) {
          return charsetPair.getValue();
        }
      }
    }
  }
  return defaultCharset;
}
项目:ROKO.Stickers-Android    文件:HttpUtils.java   
public static String getCharSet(URLConnection connection) throws IOException {
    String contentType = connection.getContentType();
    if (contentType != null) {
        HeaderValueParser parser = new BasicHeaderValueParser();
        HeaderElement[] values = BasicHeaderValueParser.parseElements(contentType, parser);
        if (values.length > 0) {
            NameValuePair param = values[0].getParameterByName("charset");
            if (param != null) {
                return param.getValue();
            }
        }
    }
    if (connection instanceof HttpURLConnection) {
        return "UTF-8";
    } else {
        throw new IOException("Unabled to determine character encoding");
    }
}
项目:lams    文件:RFC2617Scheme.java   
@Override
protected void parseChallenge(
        final CharArrayBuffer buffer, int pos, int len) throws MalformedChallengeException {
    HeaderValueParser parser = BasicHeaderValueParser.DEFAULT;
    ParserCursor cursor = new ParserCursor(pos, buffer.length());
    HeaderElement[] elements = parser.parseElements(buffer, cursor);
    if (elements.length == 0) {
        throw new MalformedChallengeException("Authentication challenge is empty");
    }
    this.params.clear();
    for (HeaderElement element : elements) {
        this.params.put(element.getName(), element.getValue());
    }
}
项目:remote-files-sync    文件:RFC2617SchemeHC4.java   
@Override
protected void parseChallenge(
        final CharArrayBuffer buffer, final int pos, final int len) throws MalformedChallengeException {
    final HeaderValueParser parser = BasicHeaderValueParserHC4.INSTANCE;
    final ParserCursor cursor = new ParserCursor(pos, buffer.length());
    final HeaderElement[] elements = parser.parseElements(buffer, cursor);
    if (elements.length == 0) {
        throw new MalformedChallengeException("Authentication challenge is empty");
    }
    this.params.clear();
    for (final HeaderElement element : elements) {
        this.params.put(element.getName().toLowerCase(Locale.ENGLISH), element.getValue());
    }
}
项目:purecloud-iot    文件:RFC2617Scheme.java   
@Override
protected void parseChallenge(
        final CharArrayBuffer buffer, final int pos, final int len) throws MalformedChallengeException {
    final HeaderValueParser parser = BasicHeaderValueParser.INSTANCE;
    final ParserCursor cursor = new ParserCursor(pos, buffer.length());
    final HeaderElement[] elements = parser.parseElements(buffer, cursor);
    this.params.clear();
    for (final HeaderElement element : elements) {
        this.params.put(element.getName().toLowerCase(Locale.ROOT), element.getValue());
    }
}
项目:Visit    文件:RFC2617SchemeHC4.java   
@Override
protected void parseChallenge(
        final CharArrayBuffer buffer, final int pos, final int len) throws MalformedChallengeException {
    final HeaderValueParser parser = BasicHeaderValueParserHC4.INSTANCE;
    final ParserCursor cursor = new ParserCursor(pos, buffer.length());
    final HeaderElement[] elements = parser.parseElements(buffer, cursor);
    if (elements.length == 0) {
        throw new MalformedChallengeException("Authentication challenge is empty");
    }
    this.params.clear();
    for (final HeaderElement element : elements) {
        this.params.put(element.getName().toLowerCase(Locale.ENGLISH), element.getValue());
    }
}
项目:cJUnit-mc626    文件:RFC2617Scheme.java   
@Override
protected void parseChallenge(
        final CharArrayBuffer buffer, int pos, int len) throws MalformedChallengeException {
    HeaderValueParser parser = BasicHeaderValueParser.DEFAULT;
    ParserCursor cursor = new ParserCursor(pos, buffer.length()); 
    HeaderElement[] elements = parser.parseElements(buffer, cursor);
    if (elements.length == 0) {
        throw new MalformedChallengeException("Authentication challenge is empty");
    }

    this.params = new HashMap<String, String>(elements.length);
    for (HeaderElement element : elements) {
        this.params.put(element.getName(), element.getValue());
    }
}
项目:ZTLib    文件:RFC2617SchemeHC4.java   
@Override
protected void parseChallenge(
        final CharArrayBuffer buffer, final int pos, final int len) throws MalformedChallengeException {
    final HeaderValueParser parser = BasicHeaderValueParserHC4.INSTANCE;
    final ParserCursor cursor = new ParserCursor(pos, buffer.length());
    final HeaderElement[] elements = parser.parseElements(buffer, cursor);
    if (elements.length == 0) {
        throw new MalformedChallengeException("Authentication challenge is empty");
    }
    this.params.clear();
    for (final HeaderElement element : elements) {
        this.params.put(element.getName().toLowerCase(Locale.ENGLISH), element.getValue());
    }
}