当前位置: 首页>>代码示例>>Java>>正文


Java BasicHeaderValueParser类代码示例

本文整理汇总了Java中org.apache.http.message.BasicHeaderValueParser的典型用法代码示例。如果您正苦于以下问题:Java BasicHeaderValueParser类的具体用法?Java BasicHeaderValueParser怎么用?Java BasicHeaderValueParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BasicHeaderValueParser类属于org.apache.http.message包,在下文中一共展示了BasicHeaderValueParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parse

import org.apache.http.message.BasicHeaderValueParser; //导入依赖的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.
 *
 * @since 4.2
 */
public static List<NameValuePair> parse (final String s, final Charset charset) {
    if (s == null) {
        return Collections.emptyList();
    }
    BasicHeaderValueParser parser = BasicHeaderValueParser.DEFAULT;
    CharArrayBuffer buffer = new CharArrayBuffer(s.length());
    buffer.append(s);
    ParserCursor cursor = new ParserCursor(0, buffer.length());
    List<NameValuePair> list = new ArrayList<NameValuePair>();
    while (!cursor.atEnd()) {
        NameValuePair nvp = parser.parseNameValuePair(buffer, cursor, DELIM);
        if (nvp.getName().length() > 0) {
            list.add(new BasicNameValuePair(
                    decodeFormFields(nvp.getName(), charset),
                    decodeFormFields(nvp.getValue(), charset)));
        }
    }
    return list;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:31,代码来源:URLEncodedUtils.java

示例2: getContentTypeCharset

import org.apache.http.message.BasicHeaderValueParser; //导入依赖的package包/类
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;
}
 
开发者ID:rockscript,项目名称:rockscript,代码行数:16,代码来源:ClientResponse.java

示例3: getCharSet

import org.apache.http.message.BasicHeaderValueParser; //导入依赖的package包/类
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");
	}
}
 
开发者ID:ROKOLabs,项目名称:ROKO.Stickers-Android,代码行数:19,代码来源:HttpUtils.java

示例4: parse

import org.apache.http.message.BasicHeaderValueParser; //导入依赖的package包/类
/**
 * Returns a list of {@link org.apache.http.NameValuePair NameValuePairs} as parsed.
 *
 * @param s text to parse.
 * @since 4.2
 */
public static List<NameValuePair> parse(final String s) {
    if (s == null) {
        return Collections.emptyList();
    }
    BasicHeaderValueParser parser = BasicHeaderValueParser.DEFAULT;
    CharArrayBuffer buffer = new CharArrayBuffer(s.length());
    buffer.append(s);
    ParserCursor cursor = new ParserCursor(0, buffer.length());
    List<NameValuePair> list = new ArrayList<NameValuePair>();
    while (!cursor.atEnd()) {
        NameValuePair nvp = parser.parseNameValuePair(buffer, cursor, DELIM);
        if (nvp.getName().length() > 0) {
            list.add(new BasicNameValuePair(nvp.getName(), nvp.getValue()));
        }
    }
    return list;
}
 
开发者ID:BigAppOS,项目名称:BigApp_Discuz_Android,代码行数:24,代码来源:URLEncodedUtils.java

示例5: parse

import org.apache.http.message.BasicHeaderValueParser; //导入依赖的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.
 *
 * @since 4.2
 */
public static List<NameValuePair> parse (final String s, final Charset charset) {
	if (s == null)
		return Collections.emptyList();
	BasicHeaderValueParser parser = BasicHeaderValueParser.DEFAULT;
	CharArrayBuffer buffer = new CharArrayBuffer(s.length());
	buffer.append(s);
	ParserCursor cursor = new ParserCursor(0, buffer.length());
	List<NameValuePair> list = new ArrayList<NameValuePair>();
	while (!cursor.atEnd()) {
		NameValuePair nvp = parser.parseNameValuePair(buffer, cursor, DELIM);
		if (nvp.getName().length() > 0)
			list.add(new BasicNameValuePair(
					decodeFormFields(nvp.getName(), charset),
					decodeFormFields(nvp.getValue(), charset)));
	}
	return list;
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:29,代码来源:URLEncodedUtils.java

示例6: consume

import org.apache.http.message.BasicHeaderValueParser; //导入依赖的package包/类
public void consume(Map<String, String> result) throws IOException {
    if (httpResponse.getEntity() != null) {
        if (responseCharacterSet == null || responseCharacterSet.isEmpty()) {
            Header contentType = httpResponse.getEntity().getContentType();
            if (contentType != null) {
                String value = contentType.getValue();
                NameValuePair[] nameValuePairs = BasicHeaderValueParser.parseParameters(value, BasicHeaderValueParser.INSTANCE);
                for (NameValuePair nameValuePair : nameValuePairs) {
                    if (nameValuePair.getName().equalsIgnoreCase("charset")) {
                        responseCharacterSet = nameValuePair.getValue();
                        break;
                    }
                }
            }
            if (responseCharacterSet == null || responseCharacterSet.isEmpty()) {
                responseCharacterSet = Consts.ISO_8859_1.name();
            }
        }
        consumeResponseContent(result);
    }
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:22,代码来源:HttpResponseConsumer.java

示例7: parse

import org.apache.http.message.BasicHeaderValueParser; //导入依赖的package包/类
/**
 * Returns a list of {@link NameValuePair NameValuePairs} as deserialized from the given string
 * using the given character encoding.
 *
 * @param s
 *            text to parse.
 * @param charset
 *            Encoding to use when decoding the parameters.
 *
 * @since 4.2
 */
public static List<NameValuePair> parse (final String s, final Charset charset) {
    if (s == null) {
        return Collections.emptyList();
    }
    BasicHeaderValueParser deserializer = BasicHeaderValueParser.DEFAULT;
    CharArrayBuffer buffer = new CharArrayBuffer(s.length());
    buffer.append(s);
    ParserCursor cursor = new ParserCursor(0, buffer.length());
    List<NameValuePair> list = new ArrayList<NameValuePair>();
    while (!cursor.atEnd()) {
        NameValuePair nvp = deserializer.parseNameValuePair(buffer, cursor, DELIM);
        if (nvp.getName().length() > 0) {
            list.add(new BasicNameValuePair(
                    decodeFormFields(nvp.getName(), charset),
                    decodeFormFields(nvp.getValue(), charset)));
        }
    }
    return list;
}
 
开发者ID:sahan,项目名称:RoboZombie,代码行数:31,代码来源:URLEncodedUtils.java

示例8: parse

import org.apache.http.message.BasicHeaderValueParser; //导入依赖的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.
 * 
 * @since 4.2
 */
public static List<NameValuePair> parse(final String s, final Charset charset) {
    if (s == null) {
        return Collections.emptyList();
    }
    BasicHeaderValueParser parser = BasicHeaderValueParser.DEFAULT;
    CharArrayBuffer buffer = new CharArrayBuffer(s.length());
    buffer.append(s);
    ParserCursor cursor = new ParserCursor(0, buffer.length());
    List<NameValuePair> list = new ArrayList<NameValuePair>();
    while (!cursor.atEnd()) {
        NameValuePair nvp = parser.parseNameValuePair(buffer, cursor, DELIM);
        if (nvp.getName().length() > 0) {
            list.add(new BasicNameValuePair(decodeFormFields(nvp.getName(), charset), decodeFormFields(nvp.getValue(), charset)));
        }
    }
    return list;
}
 
开发者ID:mobilesystems,项目名称:box-java-sdk-v2,代码行数:28,代码来源:HttpClientURLEncodedUtils.java

示例9: parse

import org.apache.http.message.BasicHeaderValueParser; //导入依赖的package包/类
/**
 * Returns a list of {@link org.apache.http.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.
 * @since 4.2
 */
public static List<NameValuePair> parse(final String s, final Charset charset) {
    if (s == null) {
        return Collections.emptyList();
    }
    BasicHeaderValueParser parser = BasicHeaderValueParser.DEFAULT;
    CharArrayBuffer buffer = new CharArrayBuffer(s.length());
    buffer.append(s);
    ParserCursor cursor = new ParserCursor(0, buffer.length());
    List<NameValuePair> list = new ArrayList<NameValuePair>();
    while (!cursor.atEnd()) {
        NameValuePair nvp = parser.parseNameValuePair(buffer, cursor, DELIM);
        if (nvp.getName().length() > 0) {
            list.add(new BasicNameValuePair(
                    decodeFormFields(nvp.getName(), charset),
                    decodeFormFields(nvp.getValue(), charset)));
        }
    }
    return list;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:28,代码来源:URLEncodedUtils.java

示例10: parseChallenge

import org.apache.http.message.BasicHeaderValueParser; //导入依赖的package包/类
@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());
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:RFC2617Scheme.java

示例11: parse

import org.apache.http.message.BasicHeaderValueParser; //导入依赖的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.
 */
public static ContentType parse(
        final String s) throws ParseException, UnsupportedCharsetException {
    if (s == null) {
        throw new IllegalArgumentException("Content type may not be null");
    }
    HeaderElement[] elements = BasicHeaderValueParser.parseElements(s, null);
    if (elements.length > 0) {
        return create(elements[0]);
    } else {
        throw new ParseException("Invalid content type: " + s);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:ContentType.java

示例12: extractFileNameFrom

import org.apache.http.message.BasicHeaderValueParser; //导入依赖的package包/类
private String extractFileNameFrom(String contentDisposition) {
  HeaderElement[] elements = BasicHeaderValueParser.parseElements(contentDisposition, null);
  return Arrays.stream(elements)
      .filter(element -> "attachment".equalsIgnoreCase(element.getName()))
      .findAny()
      .map(element -> element.getParameterByName("filename"))
      .map(NameValuePair::getValue)
      .orElse("");
}
 
开发者ID:Enterprise-Content-Management,项目名称:infoarchive-sip-sdk,代码行数:10,代码来源:ContentResultFactory.java

示例13: parseChallenge

import org.apache.http.message.BasicHeaderValueParser; //导入依赖的package包/类
@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());
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:12,代码来源:RFC2617Scheme.java

示例14: parseAuthResponse

import org.apache.http.message.BasicHeaderValueParser; //导入依赖的package包/类
private static Map<String, String> parseAuthResponse(final Header authResponse) {
    final String s = authResponse.getValue();
    if (!s.startsWith("Digest ")) {
        return null;
    }
    final HeaderElement[] elements = BasicHeaderValueParser.parseElements(s.substring(7), null);
    final Map<String, String> map = new HashMap<String, String>(elements.length);
    for (final HeaderElement element : elements) {
        map.put(element.getName(), element.getValue());
    }
    return map;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:13,代码来源:TestDigestScheme.java

示例15: parseChallenge

import org.apache.http.message.BasicHeaderValueParser; //导入依赖的package包/类
@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());
    }
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:16,代码来源:RFC2617Scheme.java


注:本文中的org.apache.http.message.BasicHeaderValueParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。