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.
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:
A significant difference between HTTP/1.1 and earlier versions of HTTP is that persistent connections are the default behavior of any HTTP connection. That is, unless otherwise indicated, the client SHOULD assume that the server will maintain a persistent connection, even after error responses from the server.
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.