Markus Schönhaber wrote:
Rainer Jung:

On 12.06.2009 10:43, Markus Schönhaber wrote:

No, it's not strange at all. If the length of the response body is not
known when the response headers are sent, you obviously can't add a
Content-Length header. That has nothing to do with the HTTP version used.
... true, but an HTTP/1.0 client can also just read until the connection
is closed. That's another way of handling content of unknown length.

Yes, that's exactly what I was pointing at.
IOW, using HTTP/1.0 doesn't magically add a Content-Length header (as
the OP seems to have expected) in situations where the size of the
response body isn't known beforehand. The difference between HTTP/1.1
and HTTP/1.0 wrt this situation is simply what has to be done to enable
the client to know about the end of transmission. While 1.1 will need to
transfer the body chunked (at least with keep-alive), 1.0 doesn't know
nor care about chunked because the server will close the underlying TCP
connection when the response is completely sent.

In summary thus :

- making the request be HTTP 1.0, no matter how it's done, is not going to magically make Tomcat send the response in one chunk nor add a Content-Length header. (it may just /prevent/ it from adding a "Content-transfer-encoding: chunked" header, yes ?)

- the first-choice solution would be to have the CDN fix their software, or select another CDN which can handle chunked content.

- the second-best would be :
(presuming the OP knows at some point the real size of the data chunk that has to be sent back.) Write a servlet which obtains the data, then uses response.setContentLength(nnn), then does a response.getWriter/getOutputStream, then writes the data there. Yes ?

- if the above is not acceptable/practical, then another solution would be to intercept and buffer the full response somewhere, calculate its size, and then forward it unchunked, preceded by a proper Content-Length header.

I have written a couple of (simplistic, beginner-level) servlets which produce output. I cannot recall having had to add myself any code to add Content-transfer-encoding headers nor "chunking" the response.
So at what level in Tomcat does that happen ?
I mean, would a servlet filter intercepting the response be "early enough", or "late enough" to do that ? Or does Tomcat already decide to add this chunking header at the moment the servlet does the response.getWriter/getOutputStream, if it hasn't seen yet a Content-Length header by then ?



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to