下面列出了org.apache.http.client.methods.HttpRequestBase#reset() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
protected void cleanupAfterRequest(org.apache.http.HttpResponse response, HttpRequestBase method) {
method.reset();
if (response instanceof CloseableHttpResponse) {
try {
((CloseableHttpResponse)response).close();
} catch (IOException e) {
throw new RuntimeException("Unable to close connection", e);
}
}
}
private <T> T executeRequest(HttpRequest value, ValueTransformer<T> valueConverter) throws IOException {
HttpRequestBase request = createRequest(value);
try {
HttpResponse response = client.execute(request);
T returnValue = valueConverter.transform(response);
return returnValue;
} finally {
request.reset();
}
}
/**
* Resets the Method for reusablility.
* @param method Method to reset.
*/
void releaseConnection(HttpRequestBase method) {
if (method != null) {
method.reset();
}
}