从此wikipedia example 典型的HTTP响应可能如下所示
HTTP/1.1 200 OK
Date: Mon, 23 May 2005 22:38:34 GMT
Content-Type: text/html; charset=UTF-8
Content-Encoding: UTF-8
Content-Length: 138
Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT
Server: Apache/1.3.3.7 (Unix) (Red-Hat/Linux)
ETag: "3f80f-1b6-3e1cb03b"
Accept-Ranges: bytes
Connection: close
<html>
<head>
<title>An Example Page</title>
</head>
<body>
Hello World, this is a very simple HTML document.
</body>
</html>
在这种情况下,由于这个标题:
Connection: close
客户端将知道HTTP正文已经完成,因为TCP连接将被关闭,比如说Connection: close
没有出现,客户端仍然会知道HTTP正文已经完成,因为这个头:
Content-Length: 138
说,一旦你得到138个字节,我们就在这里完成了。但是,如果没有使用这些头文件而服务器发送Transfer-encoding: chunked
,那么浏览器如何知道响应何时完成,以便它可以转移到其他内容上?