Fuel: Way to retrieve redirection info

Created on 15 Jul 2016  路  7Comments  路  Source: kittinunf/fuel

I understand that auto redirection is implemented in #40, but how can I disable this? My use case is that I want to decide whether or not to redirect based on the Location header, but with auto-redirection I can only see the final response.

An alternative would be that I can in some way check where I have beed redirected to. But this also seems impossible鈥擨t seems to me URLs of both request and response in the callback are set to the original URL I requested from, not the final one that actually returns the non-redirection status.

Most helpful comment

I'm having the same problem that @uranusjr have, i need the headers to decide if i want to auto redirect or not, in fact my calling code should decide that.

Removing all response interceptors doesn't really 'feels' right to me.. with the current FuelManager API, i feel that i might be removing more then I need/should.

All 7 comments

Not possible yet.
Do you want to be able to disable the redirection feature? or just in specific cases?

I鈥檇 say just in specific cases. It doesn鈥檛 need to (shouldn鈥檛) be the default, but there should be a way to change the behaviour. It could work as an optional parameter like this: (taking the idea from Django鈥檚 test client API.)

Fuel.get(url)    // Follows redirects (behaviour unchanged).
Fuel.get(url, follow = true)     // Explicitly follow redirects.
Fuel.get(url, follow = false)    // Does not follow redirects.

Should be easy to implement, since we just need to move the location of the redirection interceptor to the request and not global.

@uranusjr In the meantime, you could remove responseInterceptors and add yours own in order to do whatever you want to.

Example is here;
https://github.com/kittinunf/Fuel/blob/master/fuel/src/test/kotlin/com/github/kittinunf/fuel/InterceptorTest.kt#L207

Close due to inactivity

I'm having the same problem that @uranusjr have, i need the headers to decide if i want to auto redirect or not, in fact my calling code should decide that.

Removing all response interceptors doesn't really 'feels' right to me.. with the current FuelManager API, i feel that i might be removing more then I need/should.

Agree with @uranusjr and @njasm, it's missing feature. Let's say alone way to get auth from my server is to get cookie header from first response in chain. But with auto redirection I can't do this without removeAllResponseInterceptors() which seems to be overhead in this case.

I think it should be configurable.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lionlollipop picture lionlollipop  路  3Comments

Jirayu4R7 picture Jirayu4R7  路  3Comments

Querschlag picture Querschlag  路  5Comments

iNoles picture iNoles  路  5Comments

anatolystansler picture anatolystansler  路  5Comments