👋 is there any way to change the response headers? Server is not sending
WWW-Authenticate
on 401, so the Auth plugin is not working properly. I have tried with:
client.receivePipeline.intercept(HttpReceivePipeline.Before) { response ->
if (response.status == HttpStatusCode.Unauthorized && !response.headers.contains(HttpHeaders.WWWAuthenticate)) {
val headers = buildHeaders {
appendAll(response.headers)
append(HttpHeaders.WWWAuthenticate, "Bearer")
}
proceedWith(object : HttpResponse() {
override val headers get() = headers
// delegate all other properties to original response
})
} else {
proceed()
}
}
And I can see with the debugger that this is invoked
before the header check in Ktor's
Auth
class. But still, the response passed to Auth does not include my header. It seems like the response passed to
proceedWith()
does not replace
call.response
, which is what Auth plugin reads. Any idea?