I have made a HTTP endpoint (REST in Java, Spring Framework, Apache Tomcat), in which the HTTP response has the header "Transfer-Encoding: chunked". I don't know if it is created by the servlet or the server.
I don't want that the endpoint responses that header. Is it possible to force it so as not to send that header?
This is possibly created because the response is bigger than the response buffer, so the runtime is forced to flush before the response is complete. Since headers must be sent before the response and the Content-Length
header is unknown, it sets Transfer-Encoding: chunked
instead.
You could set the output buffer size for the Tomcat connector: see here, attribute socketBuffer
for the standard and socket.appWriteBufSize
for NIO. This sets the buffer size for the entire servlet containe, probably not what you want.
You could intercept the specific URL(s) that require a bigger buffer with a servlet filter and use response.setBufferSize(NNN)
.