https://kotlinlang.org logo
#ktor
Title
# ktor
t

tim

04/07/2021, 3:22 PM
I'm using ktor's http client (tried jetty and cio) for some tests against an api which expects a jwt in the request. when the request doesn't have a jwt the server returns 401/Unauthorized. I'm confused about the decision decision as to why the client throws if the server responds with 401/unauthorised. Am i wrong in thinking that seems to be an extreme response to a valid http response?
r

Rustam Siniukov

04/07/2021, 3:24 PM
Hi, By default client throws exceptions on non 2xx requests. You may disable it by setting
expectSuccess
to
false
in client or per-request config
t

tim

04/07/2021, 3:25 PM
brilliant thank you 🙏
3 Views