Closed GoogleCodeExporter closed 9 years ago
Canceling an HTTP request that has been sent on the wire is not a good idea.
The only way to do this is by closing the connection, but the server may never
know that the client has closed so it may continue doing what it's doing. This
wastes resources and introduces network latencies.
Adding such an interface requires changes at both ends, and is difficult to
implement based on HTTP. If you really want to cancel an ongoing request, you
could call HttpRequest.executeAsync(), get a Future, and abandon it once it
times out. But again, this may cause resource waste at the server side.
Original comment by wonder...@google.com
on 30 Dec 2014 at 4:40
Right, that's why I recommended "an executeAsync method parallel to
AbstractGoogleClientRequest.execute".
Original comment by ptuc...@google.com
on 30 Dec 2014 at 6:08
There's an executeAsync() method implemented by the underlining HttpRequest
[1], you can get access to it by calling
AbstractGoogleClientRequest.buildHttpRequest() [2].
Although named as executeAsync(), it's not a true async interface. But it
should be sufficient for your case.
[1]
https://code.google.com/p/google-http-java-client/source/browse/google-http-clie
nt/src/main/java/com/google/api/client/http/HttpRequest.java#1071
[2]
https://code.google.com/p/google-api-java-client/source/browse/google-api-client
/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClientReq
uest.java#276
Original comment by wonder...@google.com
on 30 Dec 2014 at 6:49
Original issue reported on code.google.com by
ptuc...@google.com
on 11 Apr 2014 at 6:13