okhttp-OkGo
okhttp-OkGo copied to clipboard
如何禁止302重定向?
如何禁止重定向呢?我想截获重定向的location地址
在初始化okgo的时候加个拦截器:
拦截器的内容如下:
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; } }