Actually, I just remembered that's invalid. A request can't indicate its end of the request body with a Connection: Close. A server can do that for a response, but not a client with a request. I remember encountering this situation before (with a really poorly implemented custom proxy), and Roy pointed out that this is a no-no in the RFC. (You can't get away with a 'half-close.')This sounds a bit more reasonable to me. That is, send chunked if the client will accept chunked, else send a connection: close header (which will tell the client we are done sending). As a compromise, we could start off buffering and if we hit some magic threshold and we still do not know the c-l, add a connection: close header and start sending.+1. Buffering up to, say, 8KB sounds good to me. For anything larger than that, there's little harm in sending Connection: close.
So, it's either T-E or C-L. If it is C-L, we must buffer everything. No way around this. -- justin