If I have a `ktor-client` feature that has a `send...
# ktor
f
If I have a
ktor-client
feature that has a
sendPipeline
and a
receivePipeline
intercept. How can I pass values from the sendPipeline intercept to the receivePipeline intercept (e.g. a class instance and/or some value)?
a
You can use Attributes (the documentation is for the server but the client uses the same interface) to pass a value among pipelines:
Copy code
val keyForObject = AttributeKey<MyData>("")
client.sendPipeline.intercept(HttpSendPipeline.Before) {
    context.attributes.put(keyForObject, MyData())
}

client.receivePipeline.intercept(HttpReceivePipeline.State) {
    println(context.attributes[keyForObject])
}
f
Ah cool perfect. And anything can be an attribute? Including class instances?
a
Yes.
f
Cool thank you so much. I'll give it a try