-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 André,
On 8/5/2009 7:09 PM, André Warnier wrote: > Servlet Specification 2.4, SRV 5.2, Headers : > > "To be successfully transmitted back to the client, headers must be set > before the response is committed. Headers set after the response is > committed will be ignored by the servlet container." When chunked encoding is being used, HTTP allows you to include "headers" after the response by including a "final chunk" with more headers for the previous chunk. The headers you want in this chunk should be mentioned in the "Trailer" header in the previous response. (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.40) Something like this: Request: GET /huge_dynamic_thing HTTP/1.1 TE: trailers Response: Content-Encoding: Chunked Content-Type: text/plain Content-Length: 1234567890 Trailer: Etag WOWHERESALOTOFCONTENTTHATWASDYNAMICALLYGENERATED WOWHERESALOTOFCONTENTTHATWASDYNAMICALLYGENERATED WOWHERESALOTOFCONTENTTHATWASDYNAMICALLYGENERATED WOWHERESALOTOFCONTENTTHATWASDYNAMICALLYGENERATED WOWHERESALOTOFCONTENTTHATWASDYNAMICALLYGENERATED WOWHERESALOTOFCONTENTTHATWASDYNAMICALLYGENERATED .... .... (and on and on, MiB's and MiB's worth) .... WOWHERESALOTOFCONTENTTHATWASDYNAMICALLYGENERATED WOWHERESALOTOFCONTENTTHATWASDYNAMICALLYGENERATED WOWHERESALOTOFCONTENTTHATWASDYNAMICALLYGENERATED (here, you hit the Content-Length boundary) Etag: eeewhatever/12/34234/xyz (stream closes) This should be a perfectly valid HTML conversation (modulo some detail, since I don't know exactly what chunked encoding responses look like). The question is how to get Tomcat to actually emit this kind of response. If it's not supported directly by some API (which it doesn't look like it is), perhaps the appropriate content can be emitted at the "end" of the response to make it look like the servlet is generating the trailer chunk. I fine this possibility unlikely, since Tomcat is going to want to generate that final chunk itself. It may even mutate the output of the servlet to prevent such a hack. I haven't read the code, so I don't know. I suspect someone will chime-in who has expertise with Tomcat's chunking abilities. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkp63MUACgkQ9CaO5/Lv0PBKhwCfUNFDwOc9EEx9BdLZqZn1j9GI nfwAn14XxSzUXmzDUtYjfvVVoyEvTVr9 =kAA2 -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org