By default, Ktor HTTP client does follow redirections; this feature allows to follow
Location
redirects in a way that works with any HTTP engine.
Like Johannes said it probably handled in the ktor code instead of having to configure every engine to follow redirects in different ways. This means behaviour can be more consistent across engines and makes configuration easier.
а
Артём Гильмудинов
08/14/2020, 9:44 AM
Ok. I see that HttpRedirect feature is installed by default.
But it breaks okhttp interceptors contract. If we have preconfigured okhttp client with interceptors, then Application Interceptors will be called twice but should be called once.
https://square.github.io/okhttp/interceptors/
Артём Гильмудинов
08/14/2020, 9:47 AM
So if you have some kind of logging interceptor and only want log final responses without logging intermediate redirects it will not work with default ktor okhttp setup.
e
Eric Grimsborn
08/14/2020, 9:47 AM
I think in your case you should go with either client:
ktor
or
OkHttp
if you chose one configure that one. Using ktor with OkHttp means you are using OkHttp as the engine only. Any features you want you should use the ktor ones. If ktor is missing features you want you can either build them yourself, see if someone else has built them or use a client that has those features (e.g. OkHttp) instead of ktor.