I'm using Square's Retrofit Client to make simple requests from an Android App. Like so:
RestAdapter restAdapter = new RestAdapter.Builder()
.setServer(Configurations.getInstance().plistMap.get("PTBaseURL"))
.setRequestHeaders(new RequestHeaders() {
@Override
public List<Header> get() {
List<Header> headers = new ArrayList<Header>();
Header authHeader = new Header("Authorization", authType + " " + UserManager.getInstance().currentUser.token);
headers.add(authHeader);
}
return headers;
}
})
.build();
this.service = restAdapter.create(ClientInterface.class);
One endpoint redirects to a different URL (s3). For an reason not important to this question the redirect request is failing and thus my callback.failure(error)
method is being called. I need to be able to access and modify the redirect URL or request at some point, preferable in callback.failure()
. How can I do this?
Alternatively, is there a way to set something like followRedirects = false
(and intercept the redirect in this way)?
With OkHttp
:
public static void setFollowRedirects (boolean auto)
public OkHttpClient setFollowProtocolRedirects(boolean followProtocolRedirects)
With HttpURLConnection
:
public static void setFollowRedirects (boolean auto)
public void setInstanceFollowRedirects (boolean followRedirects)
See discussion here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With