Skip to content

Commit 0b05b95

Browse files
committed
Don't retry non-idempotent requests, fixes android-async-http#108
1 parent 9272f3e commit 0b05b95

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public RetryHandler(int maxRetries) {
6565
}
6666

6767
public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
68-
boolean retry;
68+
boolean retry = true;
6969

7070
Boolean b = (Boolean) context.getAttribute(ExecutionContext.HTTP_REQ_SENT);
7171
boolean sent = (b != null && b.booleanValue());
@@ -82,16 +82,13 @@ public boolean retryRequest(IOException exception, int executionCount, HttpConte
8282
} else if (!sent) {
8383
// for most other errors, retry only if request hasn't been fully sent yet
8484
retry = true;
85-
} else {
85+
}
86+
87+
if(retry) {
8688
// resend all idempotent requests
87-
HttpUriRequest currentReq = (HttpUriRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
89+
HttpUriRequest currentReq = (HttpUriRequest) context.getAttribute( ExecutionContext.HTTP_REQUEST );
8890
String requestType = currentReq.getMethod();
89-
if(!requestType.equals("POST")) {
90-
retry = true;
91-
} else {
92-
// otherwise do not retry
93-
retry = false;
94-
}
91+
retry = !requestType.equals("POST");
9592
}
9693

9794
if(retry) {

0 commit comments

Comments
 (0)