okhttp-OkGo icon indicating copy to clipboard operation
okhttp-OkGo copied to clipboard

如何禁止302重定向?

Open xiaoli-style opened this issue 4 years ago • 1 comments

如何禁止重定向呢?我想截获重定向的location地址

xiaoli-style avatar Jun 30 '20 09:06 xiaoli-style

在初始化okgo的时候加个拦截器: image

拦截器的内容如下: public class RedirectIntercepter implements Interceptor { private Context context; public RedirectIntercepter(Context context) { this.context = context; } @Override public Response intercept(Chain chain) throws IOException { Response response = chain.proceed(chain.request()); if (!TextUtils.equals(chain.request().url().toString(),response.request().url().toString())) { 接口302做处理。 } return response; } }

rimuweinuan avatar Sep 28 '20 10:09 rimuweinuan