Skip to content

Commit c774527

Browse files
committed
Merge pull request android-async-http#28 from indigotech/master
issue android-async-http#6 fix - canceling requests
2 parents cd212a0 + a468992 commit c774527

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/com/loopj/android/http/AsyncHttpRequest.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,18 @@ public void run() {
5959
}
6060
}
6161
}
62-
62+
6363
private void makeRequest() throws IOException {
64-
HttpResponse response = client.execute(request, context);
65-
if(responseHandler != null) {
66-
responseHandler.sendResponseMessage(response);
67-
}
64+
if(!Thread.currentThread().isInterrupted()) {
65+
HttpResponse response = client.execute(request, context);
66+
if(!Thread.currentThread().isInterrupted()) {
67+
if(responseHandler != null) {
68+
responseHandler.sendResponseMessage(response);
69+
}
70+
} else{
71+
//TODO: should raise InterruptedException? this block is reached whenever the request is cancelled before its response is received
72+
}
73+
}
6874
}
6975

7076
private void makeRequestWithRetries() throws ConnectException {
@@ -86,7 +92,7 @@ private void makeRequestWithRetries() throws ConnectException {
8692
// http://code.google.com/p/android/issues/detail?id=5255
8793
cause = new IOException("NPE in HttpClient" + e.getMessage());
8894
retry = retryHandler.retryRequest(cause, ++executionCount, context);
89-
}
95+
}
9096
}
9197

9298
// no retries left, crap out with exception

0 commit comments

Comments
 (0)