Thats bad that ktor client supports followsRedirec...
# ktor
g
Thats bad that ktor client supports followsRedirects only for apache client. I’d love it to have multiplatform
c
It should be
HttpRedirect
feature
Most likely we need to improve it somehow to get it clear, deprecate or rename this parameter
// cc @e5l
g
Sergey, I’ve tried val client = HttpClient() { followRedirects = true } but it doesn’t work.
c
Hm, followRedirects = false should disable it
g
Exception in thread “main” io.ktor.client.features.SendCountExceedException: Max send count 20 exceeded
followRedirects = true
c
This means that you have infinite redirect somewhere
This feature is installed by default so you don't need to touch
followRedirects
setting
The documentation page need to be updated
g
In postman I’m getting 301 Moved Permanently for my url, and if AutoRedirect is enabled I get 200 OK (as expected). Ktor gives me a crash https://pastebin.com/deaTEr44
c
This error means that there was too many redirects
g
The crash leads to “runBlocking {” line
I’m wondering how Postman works then
c
Some sessions? cookies?
g
yeah I see cookies in response. Might be a reason.
so I have to add cookie support to my client
e
Maybe we should install the Cookies feature by default and provide the switch.
g
Sergey, I took a page with test status https://httpstat.us/301 and ktor crashes on it also
it works in browser and in Postman
e
Probably it triggers the ExpectSuccess feature. Could you provide the request example?
g
Sure.
pasted to main chat
e
Yep. If you use get<String> it expects the success status to convert the response
You could catch the exception to handle unusual situation, or use get<HttpResponse> to manually check the status code and receive body
g
Ok, will try HttpResponse. The guide uses get<String> , that’s why I had it. https://ktor.io/clients/http-client/calls/requests.html
still no luck with status code http://take.ms/qYo7c
e
Could you install HttpCookies?
Copy code
val client = HttpClient {
    ...
    install(HttpCookies)
}
g
Same. Crashes
👀 1
e
Hi, @gabin. I've found out that it's a bug in the URL parser 🙂. The host was overridden, but the empty path is not. We fix it soon in ktor
1.0.1
release
g
Hi Leonid. Thanks, will be waiting for new release 🎉 !