基本概念:
HTTP持久化连接, 也称为HTTP keep-alive, 或者HTTP连接重用, 也就是说使用一个TCP连接发送和接收多个HTTP请求/响应,而不是为每个请求/响应打开一个新的连接。
HTTP 1.0:
HTTP 1.0中默认不声明Keep-Alive,需要在HTTP头加入"Connection: keep-alive",才能启用Keep-Alive。
HTTP 1.1:
HTTP 1.1中默认启用Keep-Alive,如果加入"Connection: close ",才关闭。
消息接收模式:
a) 使用消息首部字段Conent-Length (body定长)
b) 使用消息首部字段Transfer-Encoding (body不定长)
参考资料: https://en.wikipedia.org/wiki/HTTP_persistent_connection
HTTP持久化连接, 也称为HTTP keep-alive, 或者HTTP连接重用, 也就是说使用一个TCP连接发送和接收多个HTTP请求/响应,而不是为每个请求/响应打开一个新的连接。
HTTP 1.0:
HTTP 1.0中默认不声明Keep-Alive,需要在HTTP头加入"Connection: keep-alive",才能启用Keep-Alive。
HTTP 1.1:
HTTP 1.1中默认启用Keep-Alive,如果加入"Connection: close ",才关闭。
消息接收模式:
a) 使用消息首部字段Conent-Length (body定长)
b) 使用消息首部字段Transfer-Encoding (body不定长)
参考资料: https://en.wikipedia.org/wiki/HTTP_persistent_connection