當前位置: 首頁>>代碼示例>>Java>>正文


Java BasicHeaderValueParserHC4類代碼示例

本文整理匯總了Java中org.apache.http.message.BasicHeaderValueParserHC4的典型用法代碼示例。如果您正苦於以下問題:Java BasicHeaderValueParserHC4類的具體用法?Java BasicHeaderValueParserHC4怎麽用?Java BasicHeaderValueParserHC4使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BasicHeaderValueParserHC4類屬於org.apache.http.message包,在下文中一共展示了BasicHeaderValueParserHC4類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parse

import org.apache.http.message.BasicHeaderValueParserHC4; //導入依賴的package包/類
/**
 * Returns a list of {@link NameValuePair NameValuePairs} as parsed from the given string using the given character
 * encoding.
 *
 * @param s
 *            text to parse.
 * @param charset
 *            Encoding to use when decoding the parameters.
 * @param parameterSeparator
 *            The characters used to separate parameters, by convention, {@code '&'} and {@code ';'}.
 * @return a list of {@link NameValuePair} as built from the URI's query portion.
 *
 * @since 4.3
 */
public static List<NameValuePair> parse(final String s, final Charset charset, final char... parameterSeparator) {
    if (s == null) {
        return Collections.emptyList();
    }
    final BasicHeaderValueParserHC4 parser = BasicHeaderValueParserHC4.INSTANCE;
    final CharArrayBuffer buffer = new CharArrayBuffer(s.length());
    buffer.append(s);
    final ParserCursor cursor = new ParserCursor(0, buffer.length());
    final List<NameValuePair> list = new ArrayList<NameValuePair>();
    while (!cursor.atEnd()) {
        final NameValuePair nvp = parser.parseNameValuePair(buffer, cursor, parameterSeparator);
        if (nvp.getName().length() > 0) {
            list.add(new BasicNameValuePair(
                    decodeFormFields(nvp.getName(), charset),
                    decodeFormFields(nvp.getValue(), charset)));
        }
    }
    return list;
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:34,代碼來源:URLEncodedUtilsHC4.java

示例2: parse

import org.apache.http.message.BasicHeaderValueParserHC4; //導入依賴的package包/類
/**
 * Parses textual representation of <code>Content-Type</code> value.
 *
 * @param s text
 * @return content type
 * @throws ParseException if the given text does not represent a valid
 * <code>Content-Type</code> value.
 * @throws UnsupportedCharsetException Thrown when the named charset is not available in
 * this instance of the Java virtual machine
 */
public static ContentType parse(
        final String s) throws ParseException, UnsupportedCharsetException {
    Args.notNull(s, "Content type");
    final CharArrayBuffer buf = new CharArrayBuffer(s.length());
    buf.append(s);
    final ParserCursor cursor = new ParserCursor(0, s.length());
    final HeaderElement[] elements = BasicHeaderValueParserHC4.INSTANCE.parseElements(buf, cursor);
    if (elements.length > 0) {
        return create(elements[0]);
    } else {
        throw new ParseException("Invalid content type: " + s);
    }
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:24,代碼來源:ContentType.java

示例3: parseChallenge

import org.apache.http.message.BasicHeaderValueParserHC4; //導入依賴的package包/類
@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());
    }
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:15,代碼來源:RFC2617SchemeHC4.java


注:本文中的org.apache.http.message.BasicHeaderValueParserHC4類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。