Hello all 🙂
Is there any way in Ktor Server to remove an HTTP Header once it has been added to the
ResponseHeaders
in the
ApplicationResponse
?
I've multiple mircoservices which all use some plugins like DefaultHeaders, CORS and HSTS. All of these plugins sets some HTTP headers to the application / root route. This stuff is outsourced to some kind of base module in a separate library which is used by all my services.
Now I have a single route in a single mircoservice where I don't want to have alle theses default headers. But I've found no way to remove them.
I have found this older workaorund here: [Question] Override/Add Headers to response to ktor client. But that doesn't seem to work anymore with Ktor 2 cause you now have the
PipelineContext
as receiver with the contained
ApplicationCall
, from which the headers can not be removed.
a
Aleksei Tirman [JB]
05/07/2024, 9:21 AM
Unfortunately, that's impossible at the moment.
🤔 1
s
Sam Ordonez
05/09/2024, 3:05 AM
here...
Sam Ordonez
05/09/2024, 3:07 AM
however, someone replied in a reposted thread I made, and I found a solution for it,
using "ktor.storage.driverClassName" instead of "storage.driverclassName"