aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKoushik Dutta <koushd@gmail.com>2015-03-07 14:03:03 -1000
committerKoushik Dutta <koushd@gmail.com>2015-03-07 14:03:03 -1000
commitd9975f4f5b51ccc3f3dcfaca0221f8cd0639ddbb (patch)
tree44fac6f75691245bd30e573d74b86f31694a42fa
parent4c85f8686eaf5dd33597d22b3ffa2f8e6f0db211 (diff)
downloadAndroidAsync-d9975f4f5b51ccc3f3dcfaca0221f8cd0639ddbb.tar.gz
AndroidAsync-d9975f4f5b51ccc3f3dcfaca0221f8cd0639ddbb.tar.bz2
AndroidAsync-d9975f4f5b51ccc3f3dcfaca0221f8cd0639ddbb.zip
Reverting as this is causing tests to fail. Common behavior is to accept the POST
and then redirect to another page. This causes the POST to happen twice. Revert "Redirected requests now keep the same request method, body and headers as the original one." This reverts commit 6ae6e0c38b025fe87c3ace8599d92b055231b738.
-rw-r--r--AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpClient.java17
1 files changed, 4 insertions, 13 deletions
diff --git a/AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpClient.java b/AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpClient.java
index f08d99a..6382494 100644
--- a/AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpClient.java
+++ b/AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpClient.java
@@ -27,7 +27,6 @@ import com.koushikdutta.async.parser.JSONObjectParser;
import com.koushikdutta.async.parser.StringParser;
import com.koushikdutta.async.stream.OutputStreamDataCallback;
-import org.apache.http.NameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
@@ -357,7 +356,7 @@ public class AsyncHttpClient {
Headers headers = mHeaders;
int responseCode = code();
if ((responseCode == HttpURLConnection.HTTP_MOVED_PERM || responseCode == HttpURLConnection.HTTP_MOVED_TEMP || responseCode == 307) && request.getFollowRedirect()) {
- String location = headers.get("Location");
+ String location = headers.get("Location");
Uri redirect;
try {
redirect = Uri.parse(location);
@@ -369,7 +368,7 @@ public class AsyncHttpClient {
reportConnectedCompleted(cancel, e, this, request, callback);
return;
}
- final String method = request.getMethod();
+ final String method = request.getMethod().equals(AsyncHttpHead.METHOD) ? AsyncHttpHead.METHOD : AsyncHttpGet.METHOD;
AsyncHttpRequest newReq = new AsyncHttpRequest(redirect, method);
newReq.executionTime = request.executionTime;
newReq.logLevel = request.logLevel;
@@ -377,16 +376,8 @@ public class AsyncHttpClient {
newReq.proxyHost = request.proxyHost;
newReq.proxyPort = request.proxyPort;
setupAndroidProxy(newReq);
-
- // Copy all headers from the old request to the new one (except for "host" -
- // keeping this in will make the redirect happen again!
- for (NameValuePair entry : request.getHeaders().getMultiMap()) {
- if (!entry.getName().toLowerCase().equals("host")) {
- copyHeader(request, newReq, entry.getName());
- }
- }
-
- newReq.setBody(request.getBody());
+ copyHeader(request, newReq, "User-Agent");
+ copyHeader(request, newReq, "Range");
request.logi("Redirecting");
newReq.logi("Redirected");
execute(newReq, redirectCount + 1, cancel, callback);