I am having an issue with Volley and 301/302 redirects, specifically from http -> https. I am making API calls to a server that in the near future will be issuing a 301 redirect when calling http instead of https.
I am getting a ServerError on Response.ErrorListener.
I have read some solutions here, but most of them are 1+ years old.
What is the best option?
Modify the Volley code to handle the 301/302 in the BasicNetwork class and Request class.
Use an OkHttp3 stack instead of the default HttpStack of Volley. If so which one is recommended. I have seen multiple implementations.
Code Sample
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, "http://www.server.com/api-path, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
VolleySingleton.getInstance(this).addToRequestQueue(jsonObjectRequest);
I am getting VolleyError of com.android.volley.ServerError with networkResponse.statusCode = 301. The server is returning the 301 with the location of https://www.server.com/api-path