I am increasing the size of the response buffer with ServletResponse.setBufferSize, but Tomcat 7 still throws an exception that the buffer size is not large enough. Is this a bug in Tomcat 7.0.32?
Here is my pseudo / code -
@Override
protected void writeInternal(Object o, HttpOutputMessage outputMessage)
throws IOException, HttpMessageNotWritableException {
if (some condition)
{
((ServletServerHttpResponse)outputMessage).getServletResponse().setBufferSize(Integer.MAX_VALUE);
outputMessage.getHeaders().set("Custom-Header", gson.toJson(big payload));
}
This is an exception -
org.apache.coyote.http11.HeadersTooLargeException: An attempt was made to write more data to the response headers than there was a place in the buffer. Increase maxHttpHeaderSize on the connector or write less data in the response headers.
Do I need to reset the buffer? reset()does not work.
EDIT: I'm looking for an opportunity to change the maximum header size at the individual response level based on "some state".
source
share