I think android volley can't handle redirect responses by default (?)
But, we make URLConnection, which volley uses on android 2.3 (API 9) or higher(?), handles redirects with setFollowRedirects.
You can override HurlStack.createConnection() or simply call HttpURLConnection.setFollowRedirects().
Sets the flag of whether this connection will follow redirects returned by the remote server.
| |
Sets whether this connection follows redirects.
|
https://android.googlesource.com/platform/frameworks/volley/+/master/src/com/android/volley/toolbox/HurlStack.java
- protected HttpURLConnection createConnection(URL url) throws IOException {
- return (HttpURLConnection) url.openConnection();
- }
But, it still can't handle twipic images.
The reason why was that setFollowRedirects doesn't allow HTTP <--> HTTP redirects.
http://developer.android.com/reference/java/net/HttpURLConnection.html
Response Handling
HttpURLConnection
will follow up to five HTTP redirects. It will follow redirects from one origin server to another. This implementation doesn't follow redirects from HTTPS to HTTP or vice versa.If you still want to fix it, modify the source code of the volley, please.
http://stackoverflow.com/questions/17481964/android-volley-to-handle-redirect
http://stackoverflow.com/questions/19787999/unexpected-response-code-302-for-volley-image-request
No comments:
Post a Comment