本文整理匯總了Java中org.apache.commons.httpclient.methods.HeadMethod.getResponseHeaders方法的典型用法代碼示例。如果您正苦於以下問題:Java HeadMethod.getResponseHeaders方法的具體用法?Java HeadMethod.getResponseHeaders怎麽用?Java HeadMethod.getResponseHeaders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.httpclient.methods.HeadMethod
的用法示例。
在下文中一共展示了HeadMethod.getResponseHeaders方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: head
import org.apache.commons.httpclient.methods.HeadMethod; //導入方法依賴的package包/類
/**
* Send a HEAD request
* @param cluster the cluster definition
* @param path the path or URI
* @param headers the HTTP headers to include in the request
* @return a Response object with response detail
* @throws IOException
*/
public Response head(Cluster cluster, String path, Header[] headers)
throws IOException {
HeadMethod method = new HeadMethod();
try {
int code = execute(cluster, method, null, path);
headers = method.getResponseHeaders();
return new Response(code, headers, null);
} finally {
method.releaseConnection();
}
}
示例2: updateResponseHeaders
import org.apache.commons.httpclient.methods.HeadMethod; //導入方法依賴的package包/類
/**
*
* @return
* @throws IOException
* @throws JDOMException
*/
public void updateResponseHeaders() {
log.debug("updateResponseHeaders() - Retrieving HTTP HEAD for '{}'", _resourceUrl);
// Go get the HEAD for the catalog:
HttpClient httpClient = new HttpClient();
HeadMethod headReq = new HeadMethod(_resourceUrl);
try {
int statusCode = httpClient.executeMethod(headReq);
if (statusCode != HttpStatus.SC_OK) {
log.error("Unable to HEAD s3 object: " + _resourceUrl);
}
else {
_responseHeaders = headReq.getResponseHeaders();
}
} catch (Exception e) {
log.error("Unable to HEAD the resource: {} Error Msg: {}",_resourceUrl,e.getMessage());
}
}