Change Redirect Policy of Volley Framework

后端 未结 4 1937
别跟我提以往
别跟我提以往 2020-12-14 05:25

I am using the Volley framework in a project where I always need to handle the redirects myself to handle the headers.

How redirects are handled depends right now o

4条回答
  •  执笔经年
    2020-12-14 05:36

    If you don't care about old APIs (< 9) and you just want volley stop following redirects you can do

    RequestQueue requestQueue = Volley.newRequestQueue(context, new HurlStack() {
        @Override
        protected HttpURLConnection createConnection(URL url) throws IOException {
            HttpURLConnection connection = super.createConnection(url);
            connection.setInstanceFollowRedirects(false);
    
            return connection;
        }
    });
    

提交回复
热议问题