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


Java HttpResponse.headerIterator方法代码示例

本文整理汇总了Java中ch.boye.httpclientandroidlib.HttpResponse.headerIterator方法的典型用法代码示例。如果您正苦于以下问题:Java HttpResponse.headerIterator方法的具体用法?Java HttpResponse.headerIterator怎么用?Java HttpResponse.headerIterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ch.boye.httpclientandroidlib.HttpResponse的用法示例。


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

示例1: getKeepAliveDuration

import ch.boye.httpclientandroidlib.HttpResponse; //导入方法依赖的package包/类
public long getKeepAliveDuration(final HttpResponse response, final HttpContext context) {
    Args.notNull(response, "HTTP response");
    final HeaderElementIterator it = new BasicHeaderElementIterator(
            response.headerIterator(HTTP.CONN_KEEP_ALIVE));
    while (it.hasNext()) {
        final HeaderElement he = it.nextElement();
        final String param = he.getName();
        final String value = he.getValue();
        if (value != null && param.equalsIgnoreCase("timeout")) {
            try {
                return Long.parseLong(value) * 1000;
            } catch(final NumberFormatException ignore) {
            }
        }
    }
    return -1;
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:18,代码来源:DefaultConnectionKeepAliveStrategy.java

示例2: process

import ch.boye.httpclientandroidlib.HttpResponse; //导入方法依赖的package包/类
public void process(final HttpResponse response, final HttpContext context)
        throws HttpException, IOException {
    Args.notNull(response, "HTTP request");
    Args.notNull(context, "HTTP context");

    final HttpClientContext clientContext = HttpClientContext.adapt(context);

    // Obtain actual CookieSpec instance
    final CookieSpec cookieSpec = clientContext.getCookieSpec();
    if (cookieSpec == null) {
        this.log.debug("Cookie spec not specified in HTTP context");
        return;
    }
    // Obtain cookie store
    final CookieStore cookieStore = clientContext.getCookieStore();
    if (cookieStore == null) {
        this.log.debug("Cookie store not specified in HTTP context");
        return;
    }
    // Obtain actual CookieOrigin instance
    final CookieOrigin cookieOrigin = clientContext.getCookieOrigin();
    if (cookieOrigin == null) {
        this.log.debug("Cookie origin not specified in HTTP context");
        return;
    }
    HeaderIterator it = response.headerIterator(SM.SET_COOKIE);
    processCookies(it, cookieSpec, cookieOrigin, cookieStore);

    // see if the cookie spec supports cookie versioning.
    if (cookieSpec.getVersion() > 0) {
        // process set-cookie2 headers.
        // Cookie2 will replace equivalent Cookie instances
        it = response.headerIterator(SM.SET_COOKIE2);
        processCookies(it, cookieSpec, cookieOrigin, cookieStore);
    }
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:37,代码来源:ResponseProcessCookies.java

示例3: getAllowedMethods

import ch.boye.httpclientandroidlib.HttpResponse; //导入方法依赖的package包/类
public Set<String> getAllowedMethods(final HttpResponse response) {
    Args.notNull(response, "HTTP response");

    final HeaderIterator it = response.headerIterator("Allow");
    final Set<String> methods = new HashSet<String>();
    while (it.hasNext()) {
        final Header header = it.nextHeader();
        final HeaderElement[] elements = header.getElements();
        for (final HeaderElement element : elements) {
            methods.add(element.getName());
        }
    }
    return methods;
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:15,代码来源:HttpOptions.java


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