My client sets the following headers:
Transfer-Encoding: chunked
Connection: Keep-Alive
When I retrieve responses I receive a Transfer-Encoding: chunked
header but no Connection: Keep-Alive
header. For this reason I believe I may only be receiving a partial response in my client.
Now my question is:
Is it mandatory to set the Connection: Keep-Alive
property in HTTP/1.1
?
In short, no. In the absence of a
Connection
header for messages adhering to HTTP/1.1 the default is a persistent Keep-Alive connection. If a connection header is present both parties should act accordingly given that header's value.As stated by RFC 2616 Section 8.1.2:
Of course, this doesn't prevent you from explicitly setting a
Connection: close
header if you wish to close the connection once the transfer completes.