End of an HTTP Response

后端 未结 1 1194
伪装坚强ぢ
伪装坚强ぢ 2020-12-21 04:53

What indicates the end of an HTTP Response, without having a Content-Length header?

I\'ve read that in some case, that server closes the TCP connection.

相关标签:
1条回答
  • 2020-12-21 05:12

    If both the client and the server support HTTP 1.1, and the server does not know the response body size in advance (and therefore cannot send the Content-Length response header), the server should use chunked encoding, which allows the client to find the end of the response body even if the server does not close the TCP connection immediately after sending the response.

    If HTTP 1.1 cannot be used (because either the client or the server is too old), the chunked encoding cannot be used, and in such cases sending a response without the Content-Length header prevents the server from keeping the TCP connection persistent.

    0 讨论(0)
提交回复
热议问题