zoukankan      html  css  js  c++  java
  • 浏览器如何解析服务器端发送的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

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

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

    保国


  • 相关阅读:
    [BZOJ4869][洛谷P3747][六省联考2017]相逢是问候(线段树)
    [WC2014][BZOJ3435][洛谷P3920]紫荆花之恋(动态点分治+treap)
    JavaScript对象JQuery In Action
    每日一条SQL LEFT JOIN
    Div border 显示不出来的原因
    HTML列表标记:dl、dt、dd
    The Effective Executive 笔记 一
    c# 解析JSON的几种办法
    使用if else 容易犯的错
    每日一句SQL:内联视图
  • 原文地址:https://www.cnblogs.com/baoguo/p/1318425.html
Copyright © 2011-2022 走看看