本文整理汇总了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);
}
}
}
示例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);
}
}
}
}
}
示例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);
}
示例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);
}
}
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}
示例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");
}
}
示例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);
}
示例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());
}
}
}
示例11: hasSupportedEtagValidator
import ch.boye.httpclientandroidlib.HttpRequest; //导入方法依赖的package包/类
private boolean hasSupportedEtagValidator(final HttpRequest request) {
return request.containsHeader(HeaderConstants.IF_NONE_MATCH);
}