Background
For server to server communication we are hashing request/response payloads with a shared key and storing the hash in a http header.
Issue
We are running into an issue with a controller returning a large payload (base64 string of a pdf doc) and the http header containing the hash is not being written to the response. This appears to be due to exceeding the size limit of 8KB (8192). See this post for more information on the size limit for Tomcat 7: Is there a practical HTTP Header length limit?
Solution Tried
I tried setting the following tomcat settings which did not have an effect:
maxHttpHeaderSize="16384" maxTrailerSize="-1" maxExtensionSize="-1" socket.appReadBufSize="16384" socket.appWriteBufSize="16384" bufferSize="16384"
I can set the response buffer size to something greater than 8192 in the controller I do see the hash value http header written to the response. The problem with this solution is the response buffer size is set for subsequent responses that use the same thread. If you try to set the buffer size back to 8192 you will get an exception : "Cannot change buffer size after data has been written"
class TestController { def index() { response.setBufferSize( 9216 ) def size = 8193 render "A" * size } }
System Information
Grails 2.5.2
Tomcat 7
Java 1.8 Build 66
Windows 7 Enterprise 64 bit
https://tomcat.apache.org/tomcat-7.0-doc/config/http.html
Questions
- Has anyone been able to use the tomcat settings in server.xml to solve this problem?
- Is there a point in the request life cycle that the response buffer size can be returned to the default size?
- Should I worry about setting the buffer size back? Does the buffer size affect memory consumption?