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


Java CoreProtocolPNames类代码示例

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


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

示例1: process

import ch.boye.httpclientandroidlib.params.CoreProtocolPNames; //导入依赖的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.params.CoreProtocolPNames; //导入依赖的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: init

import ch.boye.httpclientandroidlib.params.CoreProtocolPNames; //导入依赖的package包/类
/**
 * Initializes this session input buffer.
 *
 * @param instream the source input stream.
 * @param buffersize the size of the internal buffer.
 * @param params HTTP parameters.
 */
protected void init(final InputStream instream, final int buffersize, final HttpParams params) {
    Args.notNull(instream, "Input stream");
    Args.notNegative(buffersize, "Buffer size");
    Args.notNull(params, "HTTP parameters");
    this.instream = instream;
    this.buffer = new byte[buffersize];
    this.bufferpos = 0;
    this.bufferlen = 0;
    this.linebuffer = new ByteArrayBuffer(buffersize);
    final String charset = (String) params.getParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET);
    this.charset = charset != null ? Charset.forName(charset) : Consts.ASCII;
    this.ascii = this.charset.equals(Consts.ASCII);
    this.decoder = null;
    this.maxLineLen = params.getIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, -1);
    this.minChunkLimit = params.getIntParameter(CoreConnectionPNames.MIN_CHUNK_LIMIT, 512);
    this.metrics = createTransportMetrics();
    final CodingErrorAction a1 = (CodingErrorAction) params.getParameter(
            CoreProtocolPNames.HTTP_MALFORMED_INPUT_ACTION);
    this.onMalformedCharAction = a1 != null ? a1 : CodingErrorAction.REPORT;
    final CodingErrorAction a2 = (CodingErrorAction) params.getParameter(
            CoreProtocolPNames.HTTP_UNMAPPABLE_INPUT_ACTION);
    this.onUnmappableCharAction = a2 != null? a2 : CodingErrorAction.REPORT;
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:31,代码来源:AbstractSessionInputBuffer.java

示例4: init

import ch.boye.httpclientandroidlib.params.CoreProtocolPNames; //导入依赖的package包/类
protected void init(final OutputStream outstream, final int buffersize, final HttpParams params) {
    Args.notNull(outstream, "Input stream");
    Args.notNegative(buffersize, "Buffer size");
    Args.notNull(params, "HTTP parameters");
    this.outstream = outstream;
    this.buffer = new ByteArrayBuffer(buffersize);
    final String charset = (String) params.getParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET);
    this.charset = charset != null ? Charset.forName(charset) : Consts.ASCII;
    this.ascii = this.charset.equals(Consts.ASCII);
    this.encoder = null;
    this.minChunkLimit = params.getIntParameter(CoreConnectionPNames.MIN_CHUNK_LIMIT, 512);
    this.metrics = createTransportMetrics();
    final CodingErrorAction a1 = (CodingErrorAction) params.getParameter(
            CoreProtocolPNames.HTTP_MALFORMED_INPUT_ACTION);
    this.onMalformedCharAction = a1 != null ? a1 : CodingErrorAction.REPORT;
    final CodingErrorAction a2 = (CodingErrorAction) params.getParameter(
            CoreProtocolPNames.HTTP_UNMAPPABLE_INPUT_ACTION);
    this.onUnmappableCharAction = a2 != null? a2 : CodingErrorAction.REPORT;
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:20,代码来源:AbstractSessionOutputBuffer.java

示例5: getRequestConfig

import ch.boye.httpclientandroidlib.params.CoreProtocolPNames; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static RequestConfig getRequestConfig(final HttpParams params) {
    return RequestConfig.custom()
            .setSocketTimeout(params.getIntParameter(
                    CoreConnectionPNames.SO_TIMEOUT, 0))
            .setStaleConnectionCheckEnabled(params.getBooleanParameter(
                    CoreConnectionPNames.STALE_CONNECTION_CHECK, true))
            .setConnectTimeout(params.getIntParameter(
                    CoreConnectionPNames.CONNECTION_TIMEOUT, 0))
            .setExpectContinueEnabled(params.getBooleanParameter(
                    CoreProtocolPNames.USE_EXPECT_CONTINUE, false))
            .setProxy((HttpHost) params.getParameter(
                    ConnRoutePNames.DEFAULT_PROXY))
            .setLocalAddress((InetAddress) params.getParameter(
                    ConnRoutePNames.LOCAL_ADDRESS))
            .setProxyPreferredAuthSchemes((Collection<String>) params.getParameter(
                    AuthPNames.PROXY_AUTH_PREF))
            .setTargetPreferredAuthSchemes((Collection<String>) params.getParameter(
                    AuthPNames.TARGET_AUTH_PREF))
            .setAuthenticationEnabled(params.getBooleanParameter(
                    ClientPNames.HANDLE_AUTHENTICATION, true))
            .setCircularRedirectsAllowed(params.getBooleanParameter(
                    ClientPNames.ALLOW_CIRCULAR_REDIRECTS, false))
            .setConnectionRequestTimeout((int) params.getLongParameter(
                    ClientPNames.CONN_MANAGER_TIMEOUT, 0))
            .setCookieSpec((String) params.getParameter(
                    ClientPNames.COOKIE_POLICY))
            .setMaxRedirects(params.getIntParameter(
                    ClientPNames.MAX_REDIRECTS, 50))
            .setRedirectsEnabled(params.getBooleanParameter(
                    ClientPNames.HANDLE_REDIRECTS, true))
            .setRelativeRedirectsAllowed(!params.getBooleanParameter(
                    ClientPNames.REJECT_RELATIVE_REDIRECT, false))
            .build();
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:36,代码来源:HttpClientParamConfig.java


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