Skip to content

Commit

Permalink
update: 优化默认重定向逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
wyouflf committed Oct 19, 2019
1 parent 51429f3 commit 8a77efa
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.text.TextUtils;
import android.webkit.URLUtil;

import org.xutils.http.HttpMethod;
import org.xutils.http.RequestParams;
import org.xutils.http.request.HttpRequest;
import org.xutils.http.request.UriRequest;
Expand Down Expand Up @@ -33,6 +34,19 @@ public RequestParams getRedirectParams(UriRequest request) throws Throwable {
location = url + location;
}
params.setUri(location);


/* http 1.0 301 302
* http 1.1 303 307 308
*/
int code = request.getResponseCode();
if (code == 301 || code == 302 || code == 303) {
params.clearParams();
params.setMethod(HttpMethod.GET);
} /*else if (code == 307 || code == 308) {
// don't change the request method or params
}*/

return params;
}
}
Expand Down

0 comments on commit 8a77efa

Please sign in to comment.