Marc Plano-Lesay
08/31/2022, 9:08 AMonCallRespond
/ transformBody
, the data
argument I get is Any
. When printing its type when a static HTML file is served, I get a io.ktor.server.http.content.PreCompressedResponse
(I don't have compression configured on this server). Is there a way to get the actual body?Marc Plano-Lesay
08/31/2022, 9:14 AMAleksei Tirman [JB]
08/31/2022, 9:19 AMreadFrom()
method of the PreCompressedResponse
object to get a ByteReadChannel
which can be used to read a content. A content of a file isn’t actually compressed.Marc Plano-Lesay
08/31/2022, 9:20 AMPreCompressedResponse
isn't in the documentation. I also have to cast it, as it comes out as an Any
, but I can live with that.Marc Plano-Lesay
08/31/2022, 9:36 AMtransformBody
results in a 406 Not AcceptableMarc Plano-Lesay
08/31/2022, 9:38 AMMarc Plano-Lesay
08/31/2022, 9:38 AMAleksei Tirman [JB]
08/31/2022, 9:41 AMcontentType
property of PreCompressedResponse
contain a value for the Content-Type
header?Marc Plano-Lesay
08/31/2022, 9:44 AMOutgoingContent.ReadChannelContent
attributes. It does have the Content-Type
set to text/html
, which is great. I can filter out HTML files easily.
Now is there a canonical way to replace the response body by conserving the headers etc?Marc Plano-Lesay
08/31/2022, 9:47 AMtransformBody
doesn't do just that)Aleksei Tirman [JB]
08/31/2022, 10:38 AMContent-Length
header be modified too?Marc Plano-Lesay
08/31/2022, 10:41 AMString
from transformBody
seems to override every header regardless - Firefox receives a text/plain
with the proper Content-Length
Marc Plano-Lesay
08/31/2022, 10:43 AMMarc Plano-Lesay
08/31/2022, 10:48 AMOutgoingContent
subclass would do...Marc Plano-Lesay
08/31/2022, 10:53 AMWriterContent
setting both the body
and contentType
works just fineMarc Plano-Lesay
08/31/2022, 10:53 AM