Is it possible to disable following redirects in OkHttp 2.0?
android, okhttp, redirect
Solution
Yes it is possible in version 2.3.0
final OkHttpClient client = new OkHttpClient();
client.setFollowRedirects(false);
For 3.x
OkHttpClient client = new OkHttpClient().newBuilder()
.followRedirects(false)
.followSslRedirects(false)
.build();
Problem
In Android, I'd like to use the new OkHttp 2.0 to request some URLs, but I'd like more control over redirects. I've already found the option to enable or disable following HTTPS → HTTP or HTTP → HTTPS redirects, but I'd like to not follow any redirects, so I can update my GUI as soon as possible, and choose whether to follow them from application logic. I don't see an option to do this. Is it possible, and if so, how can I achieve this?