本文整理汇总了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);
}
}
}
示例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);
}
}
}
}
}
示例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;
}
示例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;
}
示例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();
}