issue #6 fix - canceling requests #28

Merged
merged 1 commit into from Dec 21, 2011
Jump to file or symbol
Failed to load files and symbols.
+12 −6
Split
@@ -59,12 +59,18 @@ public void run() {
}
}
}
-
+
private void makeRequest() throws IOException {
- HttpResponse response = client.execute(request, context);
- if(responseHandler != null) {
- responseHandler.sendResponseMessage(response);
- }
+ if(!Thread.currentThread().isInterrupted()) {
+ HttpResponse response = client.execute(request, context);
+ if(!Thread.currentThread().isInterrupted()) {
+ if(responseHandler != null) {
+ responseHandler.sendResponseMessage(response);
+ }
+ } else{
+ //TODO: should raise InterruptedException? this block is reached whenever the request is cancelled before its response is received
+ }
+ }
}
private void makeRequestWithRetries() throws ConnectException {
@@ -86,7 +92,7 @@ private void makeRequestWithRetries() throws ConnectException {
// http://code.google.com/p/android/issues/detail?id=5255
cause = new IOException("NPE in HttpClient" + e.getMessage());
retry = retryHandler.retryRequest(cause, ++executionCount, context);
- }
+ }
}
// no retries left, crap out with exception