borisdamato
03/13/2023, 4:40 PMbodyAsText
without interfering with other plugins that might want to do the same? At the moment I see that the body can only be read once, after which it gets consumed. Is there a way to prevent that? ThanksCLOVIS
03/13/2023, 4:47 PMborisdamato
03/13/2023, 4:56 PMborisdamato
03/13/2023, 4:58 PMcall.save()
following the implementation in ktor's default RequestValidator, I think that should have a similar effect, as it reads the body and copies it in a SavedHttpCall
, which also sets allowDoubleReceive: Boolean = true
on the call itself, but I'm still unable to read the body twiceborisdamato
03/13/2023, 5:02 PMSavedHttpResponse
creates a new ByteReadChannel
based on the saved body every time response.content
is called, but it doesn't seem to be working for me. When I try to read bodyAsText
again, I get a CancellationException
saying that the parent job was completedborisdamato
03/13/2023, 5:14 PMborisdamato
03/13/2023, 5:38 PMfinally
block for bodyNullable
always completes the response coroutine job, and there's no other way to access the saved responseBody in the SavedHttpCall
because getResponseContent
is protected and that's the only one creating a new ByteReadChannel with the saved contentAleksei Tirman [JB]
03/14/2023, 7:36 AMborisdamato
03/14/2023, 9:36 AMbodyAsText()
and logging it to our backend logging service
2. The second one is my version of the HttpResponseValidator
where I convert the response into my internal exception which contains the deserialized error (via body<MyError>()
+ the raw response body via bodyAsText()
).
For instance, for interceptor no.2, reading the body via bodyAsText()
makes the following body<MyError>()
throw the cancelled exception even if I transformed my call in a SavedHttpCall
by calling save()
in advance, and I assume that's because bodyNullable()
completes the job even for SavedHttpResponse
borisdamato
03/14/2023, 9:41 AMSavedHttpCall
, and I can see that it overrides getResponseContent()
by always creating a new ByteReadChannel
with the saved response content for that purpose, but then the fact that executing bodyNullable
always completes the scope's job defeats its purpose.borisdamato
03/14/2023, 9:43 AMbodyNullable
is the only way I can access the saved response content (because of the getResponseContent
), as the other APIs are not publicAleksei Tirman [JB]
03/14/2023, 2:58 PMbody
method in a HttpResponseValidator
consumes a response body as described in KTOR-4225.borisdamato
03/14/2023, 3:16 PM