What does "Connection: close" mean when used in the response message?
When the client uses the Connection: close
header in the request message, this means that it wants the server to close the connection after sending the response message.
I thought that this header is only used in the request messages, but I have noticed that it is also used in the response messages. For example:
What does this header means when used in the response message?
I think that it means that the server will close the connection after sending the response the message (even if the client has used the Connection: keep-alive
header in its request message). Am I correct?
Solution 1:
Yes, this is correct. The server can just say "I don't support your keep-alive request and will just close the connection when I am finished".
From RFC 2616, Section 14.10:
HTTP/1.1 defines the "close" connection option for the sender to
signal that the connection will be closed after completion of the
response. For example,Connection: close
in either the request or the response header fields indicates that the connection SHOULD NOT be considered `persistent' (section 8.1)
after the current request/response is complete.HTTP/1.1 applications that do not support persistent connections MUST include the "close" connection option in every message.