GET请求的响应报文笔记

我们都知道,浏览器可以发送GET请求,并解析响应,对于我们来说,我们只关心请求的URL和响应的正文,其他的东西,浏览器都给我们做好了。

这里通过wireshark,抓取访问一个简单的GET请求(http://www.rt-thread.com/service/rt-thread.txt)的过程,记录一下GET方式的详细报文。
访问结果就是显示一串文字:
在这里插入图片描述
过程中进行了抓包,两个箭头分别指向请求和响应。
在这里插入图片描述
追踪HTTP流可以看到,客户端发出的数据:

GET /service/rt-thread.txt HTTP/1.1
Host: www.rt-thread.com
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
If-None-Match: "10b-5761d43d95900-gzip"
If-Modified-Since: Tue, 18 Sep 2018 03:55:48 GMT

服务器返回的数据。

HTTP/1.1 200 OK
Server: nginx/1.10.3 (Ubuntu)
Date: Wed, 08 Apr 2020 09:29:22 GMT
Content-Type: text/plain
Content-Length: 196
Connection: keep-alive
Last-Modified: Tue, 18 Sep 2018 03:55:48 GMT
ETag: "10b-5761d43d95900-gzip"
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip

RT-Thread is an open source IoT operating system from China, which has strong scalability: from a tiny kernel running on a tiny core, for example ARM Cortex-M0, or Cortex-M3/4/7, to a rich feature system running on MIPS32, ARM Cortex-A8, ARM Cortex-A9 DualCore etc.

最后一行是我们的正文,我们可以在线计算一下,其字符串长度为265bytes。
在这里插入图片描述
观察响应的报文,数据长度(Content-Length)为196bytes,因为包头中的Vary: Accept-Encoding
Content-Encoding: gzip说明了后面传输的数据是通过gzip进行了加密的,至于为什么我数出来是265bytes,wireshark显示是267bytes,博主并不清楚……
在这里插入图片描述
所以,为了更直观的了解这个过程,可以稍微修改一下回复报文,删除其中关于gzip的部分:

HTTP/1.1 200 OK
Server: nginx/1.10.3 (Ubuntu)
Date: Wed, 08 Apr 2020 09:29:22 GMT
Content-Type: text/plain
Content-Length: 265
Connection: keep-alive
Last-Modified: Tue, 18 Sep 2018 03:55:48 GMT
Accept-Ranges: bytes

RT-Thread is an open source IoT operating system from China, which has strong scalability: from a tiny kernel running on a tiny core, for example ARM Cortex-M0, or Cortex-M3/4/7, to a rich feature system running on MIPS32, ARM Cortex-A8, ARM Cortex-A9 DualCore etc.

并使用网络调试助手建立一个服务器,使用浏览器进行访问:
在这里插入图片描述
PC端可以正常显示,说明我们的响应报文是正确的:
在这里插入图片描述
同样用手机可以正常访问。
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值