When I add a ktor 2 client plugin with `scope.requ...
# ktor
b
When I add a ktor 2 client plugin with
scope.requestPipeline.intercept(HttpRequestPipeline.Render)
I get
No request transformation found
. Without
intercept
it works (json with content negotiation). Any idea why?
a
Could you please share the code for your interceptor?
b
Copy code
scope.requestPipeline.intercept(HttpRequestPipeline.State) { body ->
            val content =
                when (body) {
                    is EmptyContent -> null
                    is String -> json.encodeToJsonElement(body)
                    is JsonElement -> body
                    else -> return@intercept
                }
            val requestAuthenticationBody = json.encodeToString(
                RequestAuthenticationBody(
                    method = context.method.value,
                    uri = context.url.encodedPath,
                    origin = hostname,
                    destination = "${context.host}:${context.port}",
                    content = content
                )
            )
            val signature = sign(requestAuthenticationBody)
            context.header(
                HttpHeaders.Authorization,
                """X-Matrix origin="$hostname",key="${signature.algorithm.name}:${signature.keyId}",sig="${signature.value}""""
            )
        }
a
Unfortunately, I cannot reproduce that error. Please share the code where an HTTP client makes a request with a body.
b
Hm... I cannot reproduce it, seems to be another problem. Sorry for the disturbance 😕
okay found the issue. My test did an assertation within the
sign
function, which seems to be catched by
intercept
and translated to this generic error message.