maxHttpHeaderSize only applies to Tomcat reading requests from clients.
It has no impact on the headers Tomcat sends to the client.
Given that the issue is size dependent and the the header is missing
only on the larger responses, I would guess that the Servlet is writing
the header after the response has been committed in those cases and is,
therefore, being lost.
In HTTP, headers usually come before the body. When generating a
response, Tomcat will buffer the response body until either there is an
explicit flush or explicit commit or the buffer is full at which point
an implicit flush occurs.
When a flush (implicit or explicit) occurs, if the response is not
committed at that point then the response is automatically committed.
Committing the response == writing the response headers.
You typically want to ensure that the Servlet writes all the headers
before it writes the response body.
There are alternative options:
1. Use a large enough response buffer to buffer the entire response.
Keep in mind you need to have enough free memory for every concurrent
request to have a buffer this large whether it uses it or not.
2. Servlet 4 (Tomcat 9 onwards) added support for trailer headers (see
RFC 7230 section 4.4). These can be used with chunked encoding and
allows header values to be written after the response body. You might
want to confirm that the client you are using supports trailer headers.
HTH,
Mark
On 11/04/2021 23:53, Rob Sargent wrote:
I should mention that this is entirely on localhost (running linux) and
using https.
On 4/11/21 8:31 AM, Rob Sargent wrote:
Thanks, I’ll go back to reading headers first.
I did not mean to imply the header content differed significantly. The
header value is always an integer (< 100).
On Apr 10, 2021, at 11:10 PM, Brian Wolfe <wolfebrian2...@gmail.com>
wrote:
So i'm not too familiar with tomcat 9. However, I did notice that
maxHttpHeaderSize
default is supposed to be 8KB in 9. That is set on the connector. Which
affects both request and response headers.
https://tomcat.apache.org/tomcat-9.0-doc/config/http.html
Did you try that?
If i'm not mistaken about a stream of content. the response headers
should
be the first thing that is received by the client. Then the body can be
split and transmitted along the connection.
On Sat, Apr 10, 2021 at 10:06 PM Rob Sargent <rsarg...@xmission.com>
wrote:
I saw this mentioned a couple years ago, on tomcat 7, but don't see
anything recent on this topic and I'm using 9.0.43. Of 59 separate
requests to same servlet three repeatedly do not have the header entry
added by the servlet to the response. The remaining 56 all have the
header/value. The three consistently lose the header.
Size matters? The 56 which succeed are on average 203 units in payload
size while the bad boys are 7K,10K,13K units. (And I'm guessing about
100 bytes per unit)
The clients streams the payload from the response, and I've tried
getting the header both before and after the stream has been read.
Any clues as to where the missing header goes? Does the servlet not
send it or is it in some /other/ response?
Thanks,
rjs
--
Thanks,
Brian Wolfe
https://www.linkedin.com/in/brian-wolfe-3136425a/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org