Note: the use case I am interested in is when a user has cancelled the upload request. In this case, I would like to clear all network traffic In case the user initiates a new upload.
-----Original Message----- From: Boxer, Aaron Sent: Friday, May 02, 2014 12:24 PM To: [email protected] Subject: Cancelling an httpclient-asynch put 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. 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. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
