浏览器如何解析服务器端发送的HTML文件

我一直为一个问题困惑,当我明白了以后,又不知道该怎么去说我要问的问题,现在我明白了,就把它帖出来,也不知道其他人遇到这个问题的时候,搜索的关键字能不能搜到,呵呵

 首先客户端发送请求:http://localhost:8080/index.html。实际上发送的数据是:

GET /index.html HTTP/1.1
Accept: */*
Accept-Language: en,zh-cn;q=0.5
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (MSIE 7.0; MSIE 7.0; Windows NT 5.1; InfoPath.1)
Host: localhost:8080

Connection: Keep-Alive



然后服务端把index.html文件发送给客户端:

<html>
<head>
<title>Welcome to BrainySoftware</title>
</head>
<body>
<img src="./images/logo1.gif">
<br>
Welcome to BrainySoftware.
<br>
<img src="./images/logo.gif">
<br>
Welcome to BrainySoftware.
</body>

</html>

接下来客户端解析index.html 文档,当他解析到特殊标签<img 的时候,向服务短发送请求:

GET /images/logo1.gif HTTP/1.1
Accept: */*
Referer: http://localhost:8080/index.html
Accept-Language: en,zh-cn;q=0.5
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (MSIE 7.0; MSIE 7.0; Windows NT 5.1; InfoPath.1)
Host: localhost:8080

Connection: Keep-Alive

 服务端把图片在发送给客户端。

然后当他解析到新的特殊标签<img 的时候,再次发送请求:

GET /images/logo.gif HTTP/1.1
Accept: */*
Referer: http://localhost:8080/index.html
Accept-Language: en,zh-cn;q=0.5
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (MSIE 7.0; MSIE 7.0; Windows NT 5.1; InfoPath.1)
Host: localhost:8080

Connection: Keep-Alive

 服务端把图片在发送给客户端。

如此往复,把整个文档显示出来,呵呵原创啊!好了,就这么多

保国


原文地址:https://www.cnblogs.com/baoguo/p/1318425.html