本文整理匯總了Java中ch.boye.httpclientandroidlib.client.methods.HttpHead類的典型用法代碼示例。如果您正苦於以下問題:Java HttpHead類的具體用法?Java HttpHead怎麽用?Java HttpHead使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
HttpHead類屬於ch.boye.httpclientandroidlib.client.methods包,在下文中一共展示了HttpHead類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRedirect
import ch.boye.httpclientandroidlib.client.methods.HttpHead; //導入依賴的package包/類
public HttpUriRequest getRedirect(
final HttpRequest request,
final HttpResponse response,
final HttpContext context) throws ProtocolException {
final URI uri = getLocationURI(request, response, context);
final String method = request.getRequestLine().getMethod();
if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) {
return new HttpHead(uri);
} else if (method.equalsIgnoreCase(HttpGet.METHOD_NAME)) {
return new HttpGet(uri);
} else {
final int status = response.getStatusLine().getStatusCode();
if (status == HttpStatus.SC_TEMPORARY_REDIRECT) {
return RequestBuilder.copy(request).setUri(uri).build();
} else {
return new HttpGet(uri);
}
}
}
示例2: isRedirectRequested
import ch.boye.httpclientandroidlib.client.methods.HttpHead; //導入依賴的package包/類
public boolean isRedirectRequested(
final HttpResponse response,
final HttpContext context) {
Args.notNull(response, "HTTP response");
final int statusCode = response.getStatusLine().getStatusCode();
switch (statusCode) {
case HttpStatus.SC_MOVED_TEMPORARILY:
case HttpStatus.SC_MOVED_PERMANENTLY:
case HttpStatus.SC_TEMPORARY_REDIRECT:
final HttpRequest request = (HttpRequest) context.getAttribute(
ExecutionContext.HTTP_REQUEST);
final String method = request.getRequestLine().getMethod();
return method.equalsIgnoreCase(HttpGet.METHOD_NAME)
|| method.equalsIgnoreCase(HttpHead.METHOD_NAME);
case HttpStatus.SC_SEE_OTHER:
return true;
default:
return false;
} //end of switch
}
示例3: getRedirect
import ch.boye.httpclientandroidlib.client.methods.HttpHead; //導入依賴的package包/類
public HttpUriRequest getRedirect(
final HttpRequest request,
final HttpResponse response,
final HttpContext context) throws ProtocolException {
final URI uri = this.handler.getLocationURI(response, context);
final String method = request.getRequestLine().getMethod();
if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) {
return new HttpHead(uri);
} else {
return new HttpGet(uri);
}
}
示例4: exists
import ch.boye.httpclientandroidlib.client.methods.HttpHead; //導入依賴的package包/類
/**
* (non-Javadoc)
*
* @see de.aflx.sardine.Sardine#exists(java.lang.String)
*/
public boolean exists(String url) throws IOException {
HttpHead head = new HttpHead(url);
return this.execute(head, new ExistsResponseHandler());
}