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

Nikky

03/29/2022, 2:44 PM
can i "edit" the headers of a incoming request? i want to see if i can read a cookie and write it into a header so that some other feature / interceptor can work with it i get that i need to do somthing like
Copy code
receivePipeline.intercept(ApplicationCallPipeline.Features) {
    val headers = call.requestheaders
    
    //TODO: add header
}
but how would i copy the request or be able to get a mutable version of the headers ?
s

Satyam Agarwal

03/29/2022, 2:55 PM
You can instead, write an interceptor to read cookie header, find what you need and add it as an attribute to call.attributes map. And then your next feature/plug-in can find key and work with its value from call.attributes. I think that should work.
n

Nikky

03/29/2022, 2:57 PM
sadly i cannot modify the other feature too much (at least without significantly more effort) which is why i am trying to hack around it
7 Views