本文整理汇总了Java中org.apache.http.client.methods.AbortableHttpRequest类的典型用法代码示例。如果您正苦于以下问题:Java AbortableHttpRequest类的具体用法?Java AbortableHttpRequest怎么用?Java AbortableHttpRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbortableHttpRequest类属于org.apache.http.client.methods包,在下文中一共展示了AbortableHttpRequest类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: releaseConnection
import org.apache.http.client.methods.AbortableHttpRequest; //导入依赖的package包/类
/**
* Forces the release of an HttpMethod's connection in a way that will
* perform all the necessary cleanup through the correct use of HttpClient
* methods.
*
* @throws IOException
*/
protected void releaseConnection() throws IOException {
if (!alreadyReleased) {
if (!underlyingStreamConsumed) {
// Underlying input stream has not been consumed, abort method
// to force connection to be closed and cleaned-up.
if (httpRequest instanceof AbortableHttpRequest) {
AbortableHttpRequest abortableHttpRequest = (AbortableHttpRequest)httpRequest;
abortableHttpRequest.abort();
}
}
inputStream.close();
alreadyReleased = true;
}
}
示例2: abortQuietly
import org.apache.http.client.methods.AbortableHttpRequest; //导入依赖的package包/类
private void abortQuietly(AbortableHttpRequest httpRequest) {
if (httpRequest != null) {
httpRequest.abort();
}
}