How to interpret “Connection: keep-alive, close”?

后端 未结 4 1012
抹茶落季
抹茶落季 2020-12-24 12:28

From what I understand, a HTTP connection could either be keep-alive or close.

I sent a HTTP request to a server:

GET /page         


        
4条回答
  •  [愿得一人]
    2020-12-24 13:23

    You are using HTTP/1.1 and you are specifying Connection: keep-alive.

    Under HTTP/1.1 all connections are keep-alive by default, and the Connection: keep-alive header has been deprecated, so you should not send it.

    Connection: keep-alive is a little hack used back in the so-called HTTP/1.0+ days. (The + stands for "hacks necessary to get it to work.")

    In HTTP: The Definitive Guide by Brian Totty, Marjorie Sayer, Sailu Reddy, Anshu Aggarwal, David Gourley by O'Reilly we read:

    Keep-alive is deprecated and no longer documented in the current HTTP/1.1 specification. However, keep-alive handshaking is still in relatively common use by browsers and servers, so HTTP implementors should be prepared to interoperate with it.

    The server might be "interoperating" and trolling you for being redundant.

提交回复
热议问题