1. 标准
RFC2616 中,对 Connection 的说明如下:
HTTP/1.1 proxies MUST parse the Connection header field before a message is forwarded and, for each connection-token in this field, remove any header field(s) from the message with the same name as the connection-token. Connection options are signaled by the presence of a connection-token in the Connection header field, not by any corresponding additional header field(s), since the additional header field may not be sent if there are no parameters associated with that connection option.
综合RFC2626 14.10、《HTTP权威指南》4.3.1、《图解HTTP》6.3.2中的说法,均指明了 Connection 头部(请求头、响应头)主要包括如下两方面的作用:
1. 控制不再转发给代理的首部字段
2. 管理持久连接
其中,我个人经常见到的是第二种用法,对第一种用法还不甚了解。
第一种用法,大概意思就是,在一个 HTTP 应用(客户端、服务器)将报文转发出之前,必须删除 Connection 首部列出的所有首部字段(多个不同的字段用逗号分隔),当然一些 end-to-end 的头部是肯定不能放进去的,例如 Cache-Control 头。