httphttp-headerschunked-encodinghttp-content-lengthhttp-chunked

If a HTTP/1.0 client requests Connection: keep-alive, will it understand chunked encoding?


If my HTTP server gets an HTTP/1.0 request with the "Connection: keep-alive" header, is it a fair bet that the client will understand "Transfer-Encoding: chunked"?

Essentially, I'm trying to decide whether to honour the "Connection: keep-alive" header from HTTP/1.0 clients. If I do honour it, then I have to use chunked coding for the reply, because I can't buffer the entire reply in order to calculate a Content-Length header.

If it is not safe to expect that an HTTP/1.0 client that requests "Connection: keep-alive" will also understand chunked coding, then I will have to close the connection after each reply. (Or have I missed something?)


Solution

  • This is a definitive "No." Quote from the spec:

    However, a persistent connection with an HTTP/1.0 client cannot make use of the chunked transfer-coding, and therefore MUST use a Content-Length for marking the ending boundary of each message.

    -- RFC 2068 §19.7.1