Hello List,
What is the best way of cancelling an httpclient-asynch put ?
Currently, I am issuing a cancel(true) on the Future I receive back from the
put call.
But, if I am sending large files, then requests that are in the middle of
sending are not cancelled.
I would like to stop all network activity as soon as possible.
Is there a way of forcing the client to abort these connections ?
Below is the code I am using to issue a put.
Thanks!
Aaron
ZeroCopyPut put = new ZeroCopyPut(
url,
file,
ContentType.DEFAULT_BINARY) {
@Override
protected HttpEntityEnclosingRequest createRequest(
final URI requestURI, final HttpEntity entity) {
HttpEntityEnclosingRequest request =
super.createRequest(requestURI, entity);
request.addHeader(HttpHeaders.CONTENT_TYPE,
HTTP.DEF_CONTENT_CHARSET.name());
return request;
}
};
return client.execute(put,
new BasicAsyncResponseConsumer() {
@Override
protected void onResponseReceived(final HttpResponse
response) throws IOException {
super.onResponseReceived(response);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode >= HttpStatus.SC_OK &&
statusCode < HttpStatus.SC_MULTIPLE_CHOICES)
{
return;
}
throw new SardineException("Unexpected
response", statusLine.getStatusCode(), statusLine.getReasonPhrase());
}
}, context, callback);
This e-mail may contain confidential and/or privileged information for the sole
use of the intended recipient.
Any review or distribution by anyone other than the person for whom it was
originally intended is strictly prohibited.
If you have received this e-mail in error, please contact the sender and delete
all copies.
Opinions, conclusions or other information contained in this e-mail may not be
that of the organization.