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

martmists

05/10/2022, 11:29 AM
How do I disable ktor (2.0.1) from sending the content-length header? It seems to be breaking tools like XRebel which add HTML code, causing the page to be truncated as result. (for reference, XRebel hooks into the Tomcat engine, not ktor directly) My current solution is to append a tag hidden in production in thymeleaf of the exact size that's truncated but it's not a great solution as I'd need to append this to every template
Copy code
</html>
<p th:remove="${config.IS_DEVELOPMENT} ? none : all" class="filler">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam sit amet lacus felis. Praesent vitae dapibus metus. Phasellus vel ornare nunc. Suspendisse potenti. Nulla cursus lacus nisl, eu accumsan velit consequat id. Proin vel mollis nulla. Aliquam fermentum elit erat, vitae imperdiet mi gravida vehicula. Cras eu dui ex. Nam pretium nulla egestas turpis eleifend porta. In pellentesque, lorem at rhoncus gravida, odio jus</p>
a

Aleksei Tirman [JB]

05/10/2022, 12:48 PM
So do you want to send a chunked response?
m

martmists

05/10/2022, 1:03 PM
Not sure what exactly that means, but I guess I just don't want ktor to set the content-length header, and instead leave it to tomcat because currently it seems tomcat may be truncating the response due to the content-length header
a

Aleksei Tirman [JB]

05/10/2022, 1:20 PM
So Ktor calculates the content length incorrectly or why Tomcat truncates it?
m

martmists

05/10/2022, 1:23 PM
Ktor calculates the length of the body generated by ktor, but xrebel adds itself to tomcat, and so it modifies the body in tomcat, but the content-length is not updated. as result, tomcat seems to be truncating the body. I did not have this issue in ktor 1.6.7 as it did not set the content-length header.
Ended up solving it by making a custom Thymeleaf plugin that uses a TextContent with null contentLength
29 Views