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


Java HttpRequest.containsHeader方法代码示例

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


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

示例1: process

import ch.boye.httpclientandroidlib.HttpRequest; //导入方法依赖的package包/类
public void process(final HttpRequest request, final HttpContext context)
    throws HttpException, IOException {
    Args.notNull(request, "HTTP request");
    if (!request.containsHeader(HTTP.USER_AGENT)) {
        String s = null;
        final HttpParams params = request.getParams();
        if (params != null) {
            s = (String) params.getParameter(CoreProtocolPNames.USER_AGENT);
        }
        if (s == null) {
            s = this.userAgent;
        }
        if (s != null) {
            request.addHeader(HTTP.USER_AGENT, s);
        }
    }
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:18,代码来源:RequestUserAgent.java

示例2: process

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

    if (!request.containsHeader(HTTP.EXPECT_DIRECTIVE)) {
        if (request instanceof HttpEntityEnclosingRequest) {
            final ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
            final HttpEntity entity = ((HttpEntityEnclosingRequest)request).getEntity();
            // Do not send the expect header if request body is known to be empty
            if (entity != null
                    && entity.getContentLength() != 0 && !ver.lessEquals(HttpVersion.HTTP_1_0)) {
                final boolean active = request.getParams().getBooleanParameter(
                        CoreProtocolPNames.USE_EXPECT_CONTINUE, this.activeByDefault);
                if (active) {
                    request.addHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE);
                }
            }
        }
    }
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:21,代码来源:RequestExpectContinue.java

示例3: process

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

    final String method = request.getRequestLine().getMethod();
    if (method.equalsIgnoreCase("CONNECT")) {
        return;
    }

    if (request.containsHeader(AUTH.WWW_AUTH_RESP)) {
        return;
    }

    // Obtain authentication state
    final AuthState authState = (AuthState) context.getAttribute(
            ClientContext.TARGET_AUTH_STATE);
    if (authState == null) {
        this.log.debug("Target auth state not set in the context");
        return;
    }
    if (this.log.isDebugEnabled()) {
        this.log.debug("Target auth state: " + authState.getState());
    }
    process(authState, request, context);
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:27,代码来源:RequestTargetAuthentication.java

示例4: process

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

    if (!request.containsHeader(HTTP.EXPECT_DIRECTIVE)) {
        if (request instanceof HttpEntityEnclosingRequest) {
            final ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
            final HttpEntity entity = ((HttpEntityEnclosingRequest)request).getEntity();
            // Do not send the expect header if request body is known to be empty
            if (entity != null
                    && entity.getContentLength() != 0 && !ver.lessEquals(HttpVersion.HTTP_1_0)) {
                final HttpClientContext clientContext = HttpClientContext.adapt(context);
                final RequestConfig config = clientContext.getRequestConfig();
                if (config.isExpectContinueEnabled()) {
                    request.addHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE);
                }
            }
        }
    }
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:21,代码来源:RequestExpectContinue.java

示例5: process

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

    final String method = request.getRequestLine().getMethod();
    if (method.equalsIgnoreCase("CONNECT")) {
        return;
    }

    if (!request.containsHeader(HTTP.CONN_DIRECTIVE)) {
        // Default policy is to keep connection alive
        // whenever possible
        request.addHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE);
    }
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:16,代码来源:RequestConnControl.java

示例6: process

import ch.boye.httpclientandroidlib.HttpRequest; //导入方法依赖的package包/类
public void process(final HttpRequest request, final HttpContext context)
        throws HttpException, IOException {
    Args.notNull(request, "HTTP request");
    if ((request instanceof HttpEntityEnclosingRequest) &&
        !request.containsHeader(HTTP.DATE_HEADER)) {
        final String httpdate = DATE_GENERATOR.getCurrentDate();
        request.setHeader(HTTP.DATE_HEADER, httpdate);
    }
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:10,代码来源:RequestDate.java

示例7: process

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

    final String method = request.getRequestLine().getMethod();
    if (method.equalsIgnoreCase("CONNECT")) {
        request.setHeader(PROXY_CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE);
        return;
    }

    final HttpClientContext clientContext = HttpClientContext.adapt(context);

    // Obtain the client connection (required)
    final RouteInfo route = clientContext.getHttpRoute();
    if (route == null) {
        this.log.debug("Connection route not set in the context");
        return;
    }

    if (route.getHopCount() == 1 || route.isTunnelled()) {
        if (!request.containsHeader(HTTP.CONN_DIRECTIVE)) {
            request.addHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE);
        }
    }
    if (route.getHopCount() == 2 && !route.isTunnelled()) {
        if (!request.containsHeader(PROXY_CONN_DIRECTIVE)) {
            request.addHeader(PROXY_CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE);
        }
    }
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:31,代码来源:RequestClientConnControl.java

示例8: process

import ch.boye.httpclientandroidlib.HttpRequest; //导入方法依赖的package包/类
/**
 * Adds the header {@code "Accept-Encoding: gzip,deflate"} to the request.
 */
public void process(
        final HttpRequest request,
        final HttpContext context) throws HttpException, IOException {

    /* Signal support for Accept-Encoding transfer encodings. */
    if (!request.containsHeader("Accept-Encoding")) {
        request.addHeader("Accept-Encoding", "gzip,deflate");
    }
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:13,代码来源:RequestAcceptEncoding.java

示例9: process

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

    if (request.containsHeader(AUTH.PROXY_AUTH_RESP)) {
        return;
    }

    final HttpRoutedConnection conn = (HttpRoutedConnection) context.getAttribute(
            ExecutionContext.HTTP_CONNECTION);
    if (conn == null) {
        this.log.debug("HTTP connection not set in the context");
        return;
    }
    final HttpRoute route = conn.getRoute();
    if (route.isTunnelled()) {
        return;
    }

    // Obtain authentication state
    final AuthState authState = (AuthState) context.getAttribute(
            ClientContext.PROXY_AUTH_STATE);
    if (authState == null) {
        this.log.debug("Proxy auth state not set in the context");
        return;
    }
    if (this.log.isDebugEnabled()) {
        this.log.debug("Proxy auth state: " + authState.getState());
    }
    process(authState, request, context);
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:33,代码来源:RequestProxyAuthentication.java

示例10: process

import ch.boye.httpclientandroidlib.HttpRequest; //导入方法依赖的package包/类
public void process(final HttpRequest request, final HttpContext context)
        throws HttpException, IOException {
    Args.notNull(request, "HTTP request");
    if (request instanceof HttpEntityEnclosingRequest) {
        if (this.overwrite) {
            request.removeHeaders(HTTP.TRANSFER_ENCODING);
            request.removeHeaders(HTTP.CONTENT_LEN);
        } else {
            if (request.containsHeader(HTTP.TRANSFER_ENCODING)) {
                throw new ProtocolException("Transfer-encoding header already present");
            }
            if (request.containsHeader(HTTP.CONTENT_LEN)) {
                throw new ProtocolException("Content-Length header already present");
            }
        }
        final ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
        final HttpEntity entity = ((HttpEntityEnclosingRequest)request).getEntity();
        if (entity == null) {
            request.addHeader(HTTP.CONTENT_LEN, "0");
            return;
        }
        // Must specify a transfer encoding or a content length
        if (entity.isChunked() || entity.getContentLength() < 0) {
            if (ver.lessEquals(HttpVersion.HTTP_1_0)) {
                throw new ProtocolException(
                        "Chunked transfer encoding not allowed for " + ver);
            }
            request.addHeader(HTTP.TRANSFER_ENCODING, HTTP.CHUNK_CODING);
        } else {
            request.addHeader(HTTP.CONTENT_LEN, Long.toString(entity.getContentLength()));
        }
        // Specify a content type if known
        if (entity.getContentType() != null && !request.containsHeader(
                HTTP.CONTENT_TYPE )) {
            request.addHeader(entity.getContentType());
        }
        // Specify a content encoding if known
        if (entity.getContentEncoding() != null && !request.containsHeader(
                HTTP.CONTENT_ENCODING)) {
            request.addHeader(entity.getContentEncoding());
        }
    }
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:44,代码来源:RequestContent.java

示例11: hasSupportedEtagValidator

import ch.boye.httpclientandroidlib.HttpRequest; //导入方法依赖的package包/类
private boolean hasSupportedEtagValidator(final HttpRequest request) {
    return request.containsHeader(HeaderConstants.IF_NONE_MATCH);
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:4,代码来源:CachedResponseSuitabilityChecker.java


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