Skip to content

Commit

Permalink
Merge pull request #2055 from dimagi/okHttpPostRetries
Browse files Browse the repository at this point in the history
Disable Retries for Post requests
  • Loading branch information
shubham1g5 authored Nov 27, 2018
2 parents e7170e3 + 20d44b0 commit a9a14c6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
7 changes: 4 additions & 3 deletions app/src/org/commcare/CommCareApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ public static CommCareNoficationManager notificationManager() {
public ModernHttpRequester buildHttpRequester(Context context, String url, Map<String, String> params,
HashMap headers, RequestBody requestBody, List<MultipartBody.Part> parts,
HTTPMethod method, @Nullable Pair<String, String> usernameAndPasswordToAuthWith,
@Nullable HttpResponseProcessor responseProcessor) {
@Nullable HttpResponseProcessor responseProcessor, boolean retry) {
return new ModernHttpRequester(new AndroidCacheDirSetup(context),
url,
params,
Expand All @@ -1099,14 +1099,15 @@ public ModernHttpRequester buildHttpRequester(Context context, String url, Map<S
parts,
CommCareNetworkServiceGenerator.createCommCareNetworkService(
HttpUtils.getCredential(usernameAndPasswordToAuthWith),
DeveloperPreferences.isEnforceSecureEndpointEnabled()),
DeveloperPreferences.isEnforceSecureEndpointEnabled(),
retry),
method,
responseProcessor);
}

public ModernHttpRequester createGetRequester(Context context, String url, Map<String, String> params,
HashMap headers, @Nullable Pair<String, String> usernameAndPasswordToAuthWith,
@Nullable HttpResponseProcessor responseProcessor) {
return buildHttpRequester(context, url, params, headers, null, null, HTTPMethod.GET, usernameAndPasswordToAuthWith, responseProcessor);
return buildHttpRequester(context, url, params, headers, null, null, HTTPMethod.GET, usernameAndPasswordToAuthWith, responseProcessor, true);
}
}
3 changes: 2 additions & 1 deletion app/src/org/commcare/network/CommcareRequestGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ public Response<ResponseBody> postMultipart(String url, List<MultipartBody.Part>
parts,
HTTPMethod.MULTIPART_POST,
new Pair(username, password),
null);
null,
false);

return requester.makeRequest();
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/org/commcare/tasks/ModernHttpTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public ModernHttpTask(Context context, String url, HashMap<String, String> param
null,
method,
usernameAndPasswordToAuthWith,
this);
this,
method.equals(HTTPMethod.GET) ? true : false);
}

@Override
Expand Down
5 changes: 3 additions & 2 deletions app/unit-tests/src/org/commcare/CommCareTestApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public void prepareTest(Object test) {
@Override
public ModernHttpRequester buildHttpRequester(Context context, String url, Map<String, String> params,
HashMap headers, RequestBody requestBody, List<MultipartBody.Part> parts,
HTTPMethod method, @Nullable Pair<String, String> usernameAndPasswordToAuthWith, HttpResponseProcessor responseProcessor) {
HTTPMethod method, @Nullable Pair<String, String> usernameAndPasswordToAuthWith, HttpResponseProcessor responseProcessor, boolean b) {
return new ModernHttpRequesterMock(new AndroidCacheDirSetup(context),
url,
params,
Expand All @@ -258,7 +258,8 @@ public ModernHttpRequester buildHttpRequester(Context context, String url, Map<S
parts,
CommCareNetworkServiceGenerator.createCommCareNetworkService(
HttpUtils.getCredential(usernameAndPasswordToAuthWith),
DeveloperPreferences.isEnforceSecureEndpointEnabled()),
DeveloperPreferences.isEnforceSecureEndpointEnabled(),
true),
method,
responseProcessor);
}
Expand Down

0 comments on commit a9a14c6

Please sign in to comment.