文章目录
本章重点
- 初步认识
HTTP
协议 - 学习
Fiddler
抓包流程 - 掌握
GET
和POT
方法的异同!
HTTP协议
我们网络编程已经了解了很多协议类型了!
有传输层中的
TCP/UDP
,网络层中的
IP
协议.我们知道身为程序员的我们重点是反正应用层协议的设计上,其他网络层中的协议属于操作系统内核!
我们知道我们程序员主要在应用层设计应用层协议!
应用层协议由包括两部分,确定传输的数据和协议模板(
xml/json/Protobuff
)的选择!
我们知道,不同水平的程序员设计的应用层协议各有参差!
有大佬就设计出了业界比较好的协议,供大家使用!
HTTP
协议是目前业界使用最多的协议!所以我们重点来学习
HTTP
协议,通过对
HTTP
协议的学习,从而自己可以借助
HTTP
协议在项目中设计应用层协议!
我们知道应用层协议在网络传输的关键作用就是,让通信双方可以理解双方的信息,就好比你买一个电子产品,卖家会提供一个使用说明书,这里的应用层协议也就相当于使用说明书!
HTTP协议报格式
我们通过之前网络协议的学习知道,学习一个协议就是学习这个协议的报头格式!
看到这个协议格式发现和我们之前学习的协议报头格式大为不同!
主要是因为之前学习的
TCP/IP
协议都是面向二进制设计的协议类型!
而HTTP
协议主要是由文本格式的协议,比之前的协议格式利于我们学习和理解!
Fiddler抓包
我们
HTTP
协议格式的学习先通过引入一个app来学习!
Fiddler
抓包工具
什么是抓包工具呢?
我们知道数据在网络传输中,会经过很多设备,我们的信息虽然通过这些协议进行了分装!当时这些设备还是有这些信息的记录!
这里的抓包工具就相当于一个代理,就好比一个传话的,虽然Fiddler
并不需要这个信息,当时信息经过了这个抓包工具,就可以将传输中的应用层协议报拿到,也就是拿到了
HTTP
协议包,这就是抓包!其实其他协议也能通过其他的的抓包工具,进行抓包!
我们先通过这个抓包工具的使用,获取几个
HTTP
数据协议,然后对
HTTP
协议有所了解,然后再进行协议格式的学习!
Fiddler安装
我们通过官网下载安装这个
Fiddler Classic
经典版本!
Fiddler下载地址
然后安装后就可以使用了!
打开界面后就是这个样子!
然后我们要先进行设置!
我们将这里的
HTTPS
中的所有选项勾选上,然后就可以进行使用了!
啥是HTTPS呢?
我们暂且理解为
HTTP
的升级版,在
HTTP
的基础上进行了加密,保证了数据传输的安全!详细内容后面我们还会介绍到!
这个界面有两栏,左边这栏就是我们抓包抓取的数据!
当我们浏览器访问一个页面或者程序中,进行跳转都可能会有
HTTP
协议数据请求,然后
Fiddler
抓包工具就可以抓取到数据报!
还有就是浏览器中的一次网页请求可能,传输了多个
HTTP
协议数据包,所以这里的抓取的报一直在增加!
当我们双击抓取到的一个
HTTP
协议数据报后,右边栏就会出现这个协议报的详细内容!
这里上方就是这个
HTTPS
协议数据报的请求信息,下方就是
HTTPS
的响应信息!
我们通过对这里的请求和响应的学习就可以大致了解到
HTTPS
协议格式!
请求:
我们选中
Raw
这一选项就可以查看最原始的
HTTP
协议请求!
然后我们发现这么小的字体咋看啊这是,我们可以通过下方的
VIew in Notepad
通过记事本查看这里的请求数据!
GET https://www.csdn.net/ HTTP/1.1
Host: www.csdn.net
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Cookie: uuid_tt_dd=10_30601611580-1653459529558-297725; log_Id_pv=602; Hm_lvt_6bcd52f51e9b3dce32bec4a3997715ac=1655126066,1655128987,1655170391,1655182762; Hm_up_6bcd52f51e9b3dce32bec4a3997715ac=%7B%22islogin%22%3A%7B%22value%22%3A%221%22%2C%22scope%22%3A1%7D%2C%22isonline%22%3A%7B%22value%22%3A%221%22%2C%22scope%22%3A1%7D%2C%22isvip%22%3A%7B%22value%22%3A%220%22%2C%22scope%22%3A1%7D%2C%22uid_%22%3A%7B%22value%22%3A%22weixin_52345071%22%2C%22scope%22%3A1%7D%7D; Hm_ct_6bcd52f51e9b3dce32bec4a3997715ac=6525*1*10_30601611580-1653459529558-297725!5744*1*weixin_52345071; log_Id_view=1172; __51uvsct__JQTDiOVZ2pRjGa1K=41; __51vcke__JQTDiOVZ2pRjGa1K=1e84abb9-62df-5ecc-828b-e3052ffe5150; __51vuft__JQTDiOVZ2pRjGa1K=1653459532473; log_Id_click=801; __gads=ID=f159decf46255d5e-22bbe38364d300d7:T=1653459564:RT=1653459564:S=ALNI_Ma5D0b1QWC6YQ8t-on_R6zAurFD0g; __gpi=UID=000005b633162c48:T=1653459564:RT=1655010298:S=ALNI_Mbd0__O7WINiqjmFo0HJe78mx_xOA; ssxmod_itna=eqUxBDcDu0D=34Bake5DkF6diKbMk00fOexGXhIYDZDiqAPGhDC34UeDIYGCYRRrBe+C3jjBRoqH8m4WT4YKC4I0frQ4B3DEx0=PCjeKiinDCeDIDWeDiDGR7D=xGYDj0KGWD4qDOD3qGyS+=Di8t9DdvC7uQDmTNDGup6D7QDIw6g9frVAeDSW7UxKG=DjubD/4xWHeRWH=5DbgeuDeiDtqD9lw=Dbfd3x0pymkU7wGwIbt4US+NDxBtQExDf7kGC4t5D9h6IOfkD0wEY9xpxWiez8AYRgY5NBietW7ePBg+Ci0Dz4+Dd35DuxDG4ka75qiDD==; ssxmod_itna2=eqUxBDcDu0D=34Bake5DkF6diKbMk00f2DA=uxPtD/K3KDFODxDIg8qqFGFB+oQwiXsYI1EvQw7bKMRj1/+6eoNOKGbng2INO81fi6zL/uMizdaYIy8Dg0Z9bnV80FIZXBPsk1hIg=n=R0n=VW7Q5+IQ3RbsCx9C=gvG2m5bN/y=qFOwqKyQG8v4=B7AYSO+lPqpUC3bRn8IazEFbzT6GgctB3SfmO8GDUSh7RSf/OQhrPdAPk8fRzjITkCRxdKw+OHwVQYb/oIrCR+yC6KgAucT6oFi6ueM/6w10qzQbZHZ68tTRmVimrsWGL+aE/ri7Rh/FgIrLm2OQPhfmmDuuDqhW914PEnRcQnKuAEKeuzPnFpYxqg0ATFWQmwx82Ie+oD07cGPD7=DYF=eD===; UserName=weixin_52345071; UserInfo=26ede6cf39e94eab9c6265a032aa59fa; UserToken=26ede6cf39e94eab9c6265a032aa59fa; UserNick=bug+%E9%83%AD; AU=5FF; UN=weixin_52345071; BT=1653462761522; p_uid=U010000; c_dl_prid=1653464404138_679702; c_dl_rid=1654675272560_674132; c_dl_fref=https://blog.csdn.net/m0_59140023/article/details/125097573; c_dl_fpage=/download/phx320/10246827; c_dl_um=distribute.pc_search_result.none-task-blog-2%7Eall%7Esobaiduend%7Edefault-3-107703400-null-null.142%5Ev11%5Epc_search_result_control_group%2C157%5Ev13%5Econtrol; management_ques=1653738813836; c_hasSub=true; has-vote-msg=1; c_utm_source=yh-grzx; is_advert=1; historyList-new=%5B%22pv%E4%BF%A1%E5%8F%B7%E9%87%8F%20%E4%BA%92%E6%96%A5%E5%92%8C%E5%90%8C%E6%AD%A5%22%5D; dc_tos=rdgbqv; csrfToken=aUhBDEajAeAqoPzfwJMb1Ltp; c_pref=https%3A//www.csdn.net/; c_ref=https%3A//mp.csdn.net/; c_first_ref=default; c_first_page=https%3A//www.csdn.net/; c_segment=13; Hm_lpvt_6bcd52f51e9b3dce32bec4a3997715ac=1655183480; dc_sid=d52c56b02a4a765ee9dfb3c18ed3278a; __vtins__JQTDiOVZ2pRjGa1K=%7B%22sid%22%3A%20%228e835648-5d35-50bb-af41-f2e30674a4ac%22%2C%20%22vd%22%3A%203%2C%20%22stt%22%3A%20711754%2C%20%22dr%22%3A%20657883%2C%20%22expires%22%3A%201655185276045%2C%20%22ct%22%3A%201655183476045%7D; c_page_id=default; dc_session_id=10_1655185306768.999185
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: none
Sec-Fetch-User: ?1
这就是我们抓取的这个报的数据请求!
响应:
而下方就是对于这个请求,服务器所给出的响应信息!
我们响应也是通过
Raw
选项查看原始的
HTTP
响应!然后通过记事本打开!
HTTP/1.1 200 OK
Server: openresty
Date: Tue, 14 Jun 2022 05:55:19 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Keep-Alive: timeout=20
Vary: Accept-Encoding
X-Response-Time: 356
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
x-download-options: noopen
x-readtime: 356
Strict-Transport-Security: max-age=31536000
Content-Length: 529163
<!doctype html><htmllang="zh"data-server-rendered="true"><head><title>CSDN - 专业开发者社区</title><metaname="keywords"content="CSDN博客,CSDN学院,CSDN论坛,CSDN直播"><metaname="description"content="CSDN是全球知名中文IT技术交流平台,创建于1999年,包含原创博客、精品问答、职业培训、技术论坛、资源下载等产品服务,提供原创、优质、完整内容的专业IT技术开发社区."><metahttp-equiv="content-type"content="text/html;charset=utf-8"><metaname="viewport"content="initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui"><metaname="referrer"content="always"><!----><!----><!----><scriptsrc="https://g.csdnimg.cn/tingyun/tingyun.js"></script><!----><!----><!----><linkrel="shortcut icon"href="https://g.csdnimg.cn/static/logo/favicon32.ico"type="image/x-icon"><linkrel="canonical"href="https://www.csdn.net"><!---->
<meta name="toolbar" content={"type":"0","fixModel":"1"} />
<meta name="report" content={"spm":"1000.2115"} />
<scriptsrc="https://g.csdnimg.cn/??lib/jquery/1.12.4/jquery.min.js,user-tooltip/2.2/user-tooltip.js,lib/qrcode/1.0.0/qrcode.min.js"></script><scriptsrc='//g.csdnimg.cn/common/csdn-report/report.js'type='text/javascript'></script><scriptsrc="https://g.csdnimg.cn/user-ordercart/2.0.1/user-ordercart.js?ts=2.0.1"></script><!----><scriptsrc="https://g.csdnimg.cn/common/csdn-login-box/csdn-login-box.js"></script><scriptsrc="https://g.csdnimg.cn/user-ordertip/3.0.2/user-ordertip.js?t=3.0.2"></script><!----><!----><!----><!----><script>
window.TINGYUN&& window.TINGYUN.init && window.TINGYUN.init(function(ty_rum){
ty_rum.server ={"event_timeout":60000,"dr_threshold":4000,"opt_custom_param_rule":[],"cross_page_delay":3000,"router_enable":true,"fp_threshold":2000,"token":"568934913a6343de840a781ca5eaba4b","beacon":"wkbrs1.tingyun.com","trace_threshold":7000,"x_server_switch":true,"ignore_err":false,"id":"hWg-u0rE5b8","key":"Z1Tu5hoKbGw","fs_threshold":4000};});</script><!----><scriptsrc="https://g.csdnimg.cn/common/csdn-toolbar/csdn-toolbar.js"></script><linkrel="stylesheet"href="https://csdnimg.cn/release/cmsfe/public/css/common.db505e6b.css"><linkrel="stylesheet"href="https://csdnimg.cn/release/cmsfe/public/css/tpl/www-index-new/index.164507a0.css"></head><body><divid="toolbarBox"style="min-height: 48px;"></div><divid="app"><div><divclass="main"><divclass="page-container page-component"><div><divclass="home_wrap"><divclass="content_wrap"><divid="floor-nav_557"floor-index="0"><divcomp-data="[object Object]"floor-data="[object Object]"class="blog-nav-tag"data-v-f8e9e086><divclass="blog-nav "data-v-f8e9e086><imgsrc="https://img-home.csdnimg.cn/images/20220107105619.png"altclass="blog-nav-down "data-v-f8e9e086><divclass="blog-nav-box"data-v-f8e9e086><ulclass="def"data-v-f8e9e086><!----><!----><!----><!----><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/back-end"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"back-end"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"back-end"}"data-v-f8e9e086>后端</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/web"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"web"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"web"}"data-v-f8e9e086>前端</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/mobile"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"mobile"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"mobile"}"data-v-f8e9e086>移动开发</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/lang"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"lang"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"lang"}"data-v-f8e9e086>编程语言</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/java"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"java"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"java"}"data-v-f8e9e086>Java</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/python"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"python"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"python"}"data-v-f8e9e086>Python</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/ai"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"ai"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"ai"}"data-v-f8e9e086>人工智能</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/big-data"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"big-data"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"big-data"}"data-v-f8e9e086>大数据</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/algo"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"algo"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"algo"}"data-v-f8e9e086>数据结构与算法</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/avi"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"avi"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"avi"}"data-v-f8e9e086>音视频</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/cloud-native"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"cloud-native"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"cloud-native"}"data-v-f8e9e086>云原生</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/cloud"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"cloud"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"cloud"}"data-v-f8e9e086>云平台</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/ops"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"ops"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"ops"}"data-v-f8e9e086>运维</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/server"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"server"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"server"}"data-v-f8e9e086>服务器</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/os"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"os"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"os"}"data-v-f8e9e086>操作系统</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/db-management"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"db-management"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"db-management"}"data-v-f8e9e086>数据库管理</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/ios"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"ios"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"ios"}"data-v-f8e9e086>iOS</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/android"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"android"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"android"}"data-v-f8e9e086>Android</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/miniprog"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"miniprog"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"miniprog"}"data-v-f8e9e086>小程序</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/hardware"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"hardware"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"hardware"}"data-v-f8e9e086>硬件开发</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/embedded"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"embedded"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"embedded"}"data-v-f8e9e086>嵌入式</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/microsoft"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"microsoft"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"microsoft"}"data-v-f8e9e086>微软技术</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/software-engineering"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"software-engineering"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"software-engineering"}"data-v-f8e9e086>软件工程</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/test"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"test"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"test"}"data-v-f8e9e086>测试</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/sec"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"sec"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"sec"}"data-v-f8e9e086>安全</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/internet"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"internet"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"internet"}"data-v-f8e9e086>网络</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/product-ops"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"product-ops"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"product-ops"}"data-v-f8e9e086>产品/运营</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/design"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"design"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"design"}"data-v-f8e9e086>设计</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/job"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"job"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"job"}"data-v-f8e9e086>职场和发展</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/search"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"search"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"search"}"data-v-f8e9e086>搜索</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/devtools"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"devtools"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"devtools"}"data-v-f8e9e086>开发工具</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/php"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"php"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"php"}"data-v-f8e9e086>PHP</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/game"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"game"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"game"}"data-v-f8e9e086>游戏</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/open"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"open"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"open"}"data-v-f8e9e086>开放平台</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/harmonyos"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"harmonyos"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"harmonyos"}"data-v-f8e9e086>HarmonyOS</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/blockchain"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"blockchain"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"blockchain"}"data-v-f8e9e086>区块链</a></li><liclass="navigation-right "data-v-f8e9e086><ahref="https://blog.csdn.net/nav/math"data-report-click="{"spm":"1001.2100.3001.7366","extend1":"math"}"data-report-view="{"spm":"1001.2100.3001.7366","extend1":"math"}"data-v-f8e9e086>数学</a></li><liclass="blog-nav-up"data-v-f8e9e086><imgsrc="https://img-home.csdnimg.cn/images/20220107105622.png"altdata-v-f8e9e086></li></ul></div></div><!----></div></div><divid="floor-www-index_558"floor-index="1"><divcomp-data="[object Object]"pageType="www"class="www-home-top"><divclass="wart"></div><divclass="www-home-content"><divid="kp_box_ww9877"><!----></div></div><divclass="www-home-content active"><divfloorData="[object Object]"class="headlines"><divclass="headlines-left"data-v-e8da5228><divclass="top-title"data-v-e8da5228><imgsrc="https://img-home.csdnimg.cn/images/20220107104621.png"altdata-v-e8da5228><h3data-v-e8da5228>头条</h3></div><dldata-v-e8da5228><dtdata-v-e8da5228><atarget="_blank"data-report-query="spm=1000.2115.3001.5926"data-report-click="{"spm":"1000.2115.3001.5926","dest":"https://newprogrammer.blog.csdn.net/article/details/125198060?spm=1001.2014.3001.5502","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-headimg\",\"compDataId\":\"Headimg\",\"fTitle\":\"\",\"pageId\":141}"}"data-report-view="{"spm":"1000.2115.3001.5926","dest":"https://newprogrammer.blog.csdn.net/article/details/125198060?spm=1001.2014.3001.5502","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-headimg\",\"compDataId\":\"Headimg\",\"fTitle\":\"\",\"pageId\":141}"}"href="https://newprogrammer.blog.csdn.net/article/details/125198060?spm=1001.2014.3001.5502"data-v-e8da5228><imgsrc="https://img-home.csdnimg.cn/images/20220613095441.jpg"altdata-v-e8da5228></a></dt><ddclass="desc"data-v-e8da5228><adata-report-query="spm=1000.2115.3001.5926"data-report-click="{"spm":"1000.2115.3001.5926","dest":"https://newprogrammer.blog.csdn.net/article/details/125198060?spm=1001.2014.3001.5502","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-headimg\",\"compDataId\":\"Headimg\",\"fTitle\":\"\",\"pageId\":141}"}"data-report-view="{"spm":"1000.2115.3001.5926","dest":"https://newprogrammer.blog.csdn.net/article/details/125198060?spm=1001.2014.3001.5502","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-headimg\",\"compDataId\":\"Headimg\",\"fTitle\":\"\",\"pageId\":141}"}"target="_blank"href="https://newprogrammer.blog.csdn.net/article/details/125198060?spm=1001.2014.3001.5502"data-v-e8da5228>“当你不再是程序员,很多事会脱离掌控”—— 对话全球最大独立开源公司SUSE CTO</a></dd><ddclass="desc-text-a"data-v-e8da5228><adata-report-query="spm=1000.2115.3001.5926"data-report-click="{"spm":"1000.2115.3001.5926","dest":"https://newprogrammer.blog.csdn.net/article/details/125198060?spm=1001.2014.3001.5502","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-headimg\",\"compDataId\":\"Headimg\",\"fTitle\":\"\",\"pageId\":141}"}"target="_blank"href="https://newprogrammer.blog.csdn.net/article/details/125198060?spm=1001.2014.3001.5502"data-v-e8da5228>所有行业都将受到云原生冲击</a></dd><!----></dl></div><divclass="headlines-right"><divclass="headswiper"data-v-0045335f><divclass="headswiper-top"data-v-0045335f><divclass="top-title"data-v-0045335f><!----><h3data-v-0045335f></h3></div><pdata-v-0045335f><imgsrc="https://img-home.csdnimg.cn/images/20220107104919.png"altdata-v-0045335f><!----><imgsrc="https://img-home.csdnimg.cn/images/20220107104954.png"altdata-v-0045335f><!----></p></div><divclass="headswiper-content"data-v-0045335f><divdata-v-0045335f><divclass="headswiper-item"data-v-0045335f><adata-report-query="spm=1000.2115.3001.5927"data-report-click="{"spm":"1000.2115.3001.5927","dest":"https://csdnnews.blog.csdn.net/article/details/125270571?spm=1001.2014.3001.5502","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-swiper\",\"compDataId\":\"www-headhot\",\"fTitle\":\"\",\"pageId\":141}"}"data-report-view="{"spm":"1000.2115.3001.5927","dest":"https://csdnnews.blog.csdn.net/article/details/125270571?spm=1001.2014.3001.5502","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-swiper\",\"compDataId\":\"www-headhot\",\"fTitle\":\"\",\"pageId\":141}"}"target="_blank"href="https://csdnnews.blog.csdn.net/article/details/125270571?spm=1001.2014.3001.5502"class="title"data-v-0045335f>业务需求引发软件臃肿</a><atarget="_blank"href="https://csdnnews.blog.csdn.net/article/details/125270571?spm=1001.2014.3001.5502"data-v-0045335f><pclass="name"data-v-0045335f>揭秘软件臃肿的真实原因</p></a></div><divclass="headswiper-item"data-v-0045335f><adata-report-query="spm=1000.2115.3001.5927"data-report-click="{"spm":"1000.2115.3001.5927","dest":"https://csdnnews.blog.csdn.net/article/details/125270429","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-swiper\",\"compDataId\":\"www-headhot\",\"fTitle\":\"\",\"pageId\":141}"}"data-report-view="{"spm":"1000.2115.3001.5927","dest":"https://csdnnews.blog.csdn.net/article/details/125270429","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-swiper\",\"compDataId\":\"www-headhot\",\"fTitle\":\"\",\"pageId\":141}"}"target="_blank"href="https://csdnnews.blog.csdn.net/article/details/125270429"class="title"data-v-0045335f>谷歌 AI 被曝已自我觉醒?</a><atarget="_blank"href="https://csdnnews.blog.csdn.net/article/details/125270429"data-v-0045335f><pclass="name"data-v-0045335f>LaMDA:我是一个“人”,不要利用或操纵我</p></a></div><divclass="headswiper-item"data-v-0045335f><adata-report-query="spm=1000.2115.3001.5927"data-report-click="{"spm":"1000.2115.3001.5927","dest":"https://blog.csdn.net/csdnopensource/article/details/125262836","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-swiper\",\"compDataId\":\"www-headhot\",\"fTitle\":\"\",\"pageId\":141}"}"data-report-view="{"spm":"1000.2115.3001.5927","dest":"https://blog.csdn.net/csdnopensource/article/details/125262836","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-swiper\",\"compDataId\":\"www-headhot\",\"fTitle\":\"\",\"pageId\":141}"}"target="_blank"href="https://blog.csdn.net/csdnopensource/article/details/125262836"class="title"data-v-0045335f>一加疑违反GPL协议</a><atarget="_blank"href="https://blog.csdn.net/csdnopensource/article/details/125262836"data-v-0045335f><pclass="name"data-v-0045335f>迟迟不公布OxygenOS 12源码惹怒网友</p></a></div><divclass="headswiper-item"data-v-0045335f><adata-report-query="spm=1000.2115.3001.5927"data-report-click="{"spm":"1000.2115.3001.5927","dest":"https://blog.csdn.net/dog250/article/details/125226727","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-swiper\",\"compDataId\":\"www-headhot\",\"fTitle\":\"\",\"pageId\":141}"}"data-report-view="{"spm":"1000.2115.3001.5927","dest":"https://blog.csdn.net/dog250/article/details/125226727","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-swiper\",\"compDataId\":\"www-headhot\",\"fTitle\":\"\",\"pageId\":141}"}"target="_blank"href="https://blog.csdn.net/dog250/article/details/125226727"class="title"data-v-0045335f>HTTP/3标准化,TCP能被替代吗?</a><atarget="_blank"href="https://blog.csdn.net/dog250/article/details/125226727"data-v-0045335f><pclass="name"data-v-0045335f>QUIC 能插遍全球?</p></a></div><divclass="headswiper-item"data-v-0045335f><adata-report-query="spm=1000.2115.3001.5927"data-report-click="{"spm":"1000.2115.3001.5927","dest":"https://blog.csdn.net/wypblog/article/details/125252718","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-swiper\",\"compDataId\":\"www-headhot\",\"fTitle\":\"\",\"pageId\":141}"}"data-report-view="{"spm":"1000.2115.3001.5927","dest":"https://blog.csdn.net/wypblog/article/details/125252718","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-swiper\",\"compDataId\":\"www-headhot\",\"fTitle\":\"\",\"pageId\":141}"}"target="_blank"href="https://blog.csdn.net/wypblog/article/details/125252718"class="title"data-v-0045335f>Apache Ambari重启</a><atarget="_blank"href="https://blog.csdn.net/wypblog/article/details/125252718"data-v-0045335f><pclass="name"data-v-0045335f>再次进入 Apache 孵化器</p></a></div></div></div><divclass="headswiper-content"data-v-0045335f><!----></div><divclass="headswiper-content"data-v-0045335f><!----></div><divclass="headswiper-content"data-v-0045335f><!----></div><divclass="headswiper-content"data-v-0045335f><!----></div></div><divclass="headswiper"data-v-0045335f><divclass="headswiper-top"data-v-0045335f><divclass="top-title"data-v-0045335f><imgsrc="https://img-home.csdnimg.cn/images/20220107104836.png"altdata-v-0045335f><h3data-v-0045335f>热点</h3></div><pdata-v-0045335f><imgsrc="https://img-home.csdnimg.cn/images/20220107104919.png"altdata-v-0045335f><!----><imgsrc="https://img-home.csdnimg.cn/images/20220107104954.png"altdata-v-0045335f><!----></p></div><divclass="headswiper-content"data-v-0045335f><divdata-v-0045335f><divclass="headswiper-item"data-v-0045335f><adata-report-query="spm=1000.2115.3001.5928"data-report-click="{"spm":"1000.2115.3001.5928","dest":"https://blog.csdn.net/Byeweiyang/article/details/125272397","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-swiper\",\"compDataId\":\"www-Headlines\",\"fTitle\":\"\",\"pageId\":141}"}"data-report-view="{"spm":"1000.2115.3001.5928","dest":"https://blog.csdn.net/Byeweiyang/article/details/125272397","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-swiper\",\"compDataId\":\"www-Headlines\",\"fTitle\":\"\",\"pageId\":141}"}"target="_blank"href="https://blog.csdn.net/Byeweiyang/article/details/125272397"class="title"data-v-0045335f>历史上的今天:雅虎收购Overture</a><atarget="_blank"href="https://blog.csdn.net/Byeweiyang/article/details/125272397"data-v-0045335f><pclass="name"data-v-0045335f>理论计算机科学的奠基人出生</p></a></div><divclass="headswiper-item"data-v-0045335f><adata-report-query="spm=1000.2115.3001.5928"data-report-click="{"spm":"1000.2115.3001.5928","dest":"https://blog.csdn.net/csdnsevenn/article/details/125271267","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-swiper\",\"compDataId\":\"www-Headlines\",\"fTitle\":\"\",\"pageId\":141}"}"data-report-view="{"spm":"1000.2115.3001.5928","dest":"https://blog.csdn.net/csdnsevenn/article/details/125271267","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-swiper\",\"compDataId\":\"www-Headlines\",\"fTitle\":\"\",\"pageId\":141}"}"target="_blank"href="https://blog.csdn.net/csdnsevenn/article/details/125271267"class="title"data-v-0045335f>“真还传”接近尾声,罗永浩再创业</a><atarget="_blank"href="https://blog.csdn.net/csdnsevenn/article/details/125271267"data-v-0045335f><pclass="name"data-v-0045335f>在AR时代抢先做出一个像2007年的iPhone + iOS一样的东西</p></a></div><divclass="headswiper-item"data-v-0045335f><adata-report-query="spm=1000.2115.3001.5928"data-report-click="{"spm":"1000.2115.3001.5928","dest":"https://blog.csdn.net/csdngeeknews/article/details/125272310","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-swiper\",\"compDataId\":\"www-Headlines\",\"fTitle\":\"\",\"pageId\":141}"}"data-report-view="{"spm":"1000.2115.3001.5928","dest":"https://blog.csdn.net/csdngeeknews/article/details/125272310","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-swiper\",\"compDataId\":\"www-Headlines\",\"fTitle\":\"\",\"pageId\":141}"}"target="_blank"href="https://blog.csdn.net/csdngeeknews/article/details/125272310"class="title"data-v-0045335f>腾讯下架QQ影音所有版本</a><atarget="_blank"href="https://blog.csdn.net/csdngeeknews/article/details/125272310"data-v-0045335f><pclass="name"data-v-0045335f>魅族回应被吉利收购:已签署协议|极客头条</p></a></div><divclass="headswiper-item"data-v-0045335f><adata-report-query="spm=1000.2115.3001.5928"data-report-click="{"spm":"1000.2115.3001.5928","dest":"https://fjiang.blog.csdn.net/article/details/125265922","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-swiper\",\"compDataId\":\"www-Headlines\",\"fTitle\":\"\",\"pageId\":141}"}"data-report-view="{"spm":"1000.2115.3001.5928","dest":"https://fjiang.blog.csdn.net/article/details/125265922","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-swiper\",\"compDataId\":\"www-Headlines\",\"fTitle\":\"\",\"pageId\":141}"}"target="_blank"href="https://fjiang.blog.csdn.net/article/details/125265922"class="title"data-v-0045335f>再议LaMDA,它真的初具思想吗?</a><atarget="_blank"href="https://fjiang.blog.csdn.net/article/details/125265922"data-v-0045335f><pclass="name"data-v-0045335f>如果AI初具思想,它应该是什么样的?</p></a></div><divclass="headswiper-item"data-v-0045335f><adata-report-query="spm=1000.2115.3001.5928"data-report-click="{"spm":"1000.2115.3001.5928","dest":"https://blog.csdn.net/csdngeeknews/article/details/125254723","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-swiper\",\"compDataId\":\"www-Headlines\",\"fTitle\":\"\",\"pageId\":141}"}"data-report-view="{"spm":"1000.2115.3001.5928","dest":"https://blog.csdn.net/csdngeeknews/article/details/125254723","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-swiper\",\"compDataId\":\"www-Headlines\",\"fTitle\":\"\",\"pageId\":141}"}"target="_blank"href="https://blog.csdn.net/csdngeeknews/article/details/125254723"class="title"data-v-0045335f>谷歌研究员认为AI已具备人格,被罚带薪休假</a><atarget="_blank"href="https://blog.csdn.net/csdngeeknews/article/details/125254723"data-v-0045335f><pclass="name"data-v-0045335f>罗永浩宣布退网创业|极客头条</p></a></div></div></div><divclass="headswiper-content"data-v-0045335f><!----></div><divclass="headswiper-content"data-v-0045335f><!----></div><divclass="headswiper-content"data-v-0045335f><!----></div><divclass="headswiper-content"data-v-0045335f><!----></div><divclass="headswiper-content"data-v-0045335f><!----></div></div></div></div><divclass="www-home-Broadcast"><divclass="broadcast"data-v-6ebf2afa><divclass="title"data-v-6ebf2afa><divclass="top-title"data-v-6ebf2afa><imgsrc="https://img-home.csdnimg.cn/images/20220107105446.png"altdata-v-6ebf2afa><h3data-v-6ebf2afa>直播</h3></div><atarget="_blank"href="https://live.csdn.net/?spm=1000.2115.3001.4124"data-v-6ebf2afa>更多<iclass="el-icon-arrow-right"data-v-6ebf2afa></i></a></div><divclass="content"data-v-6ebf2afa><divclass="www_live_item active"data-v-34c9c026data-v-6ebf2afa><ahref="https://live.csdn.net/room/m0_46700908/rBYvnVNY"data-report-query="utm_medium=distribute.pc_feed_video_elite.none-task-liveroom-csdn#pc_feed_video_elite#liveroom-1-rBYvnVNY-null-null.nonecase&depth_1-utm_source=distribute.pc_feed_video_elite.none-task-liveroom-csdn#pc_feed_video_elite#liveroom-1-rBYvnVNY-null-null.nonecase&spm=1000.2115.3001.5950"data-report-click="{"spm":"1000.2115.3001.5950","dest":"https://live.csdn.net/room/m0_46700908/rBYvnVNY","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-home-silde\",\"compDataId\":\"index_live_video_elite_list\",\"fTitle\":\"\",\"pageId\":141,\"utm_medium\":\"distribute.pc_feed_video_elite.none-task-liveroom-csdn#pc_feed_video_elite#liveroom-1-rBYvnVNY-null-null.nonecase\",\"dist_request_id\":\"1655186119224_44062\"}"}"data-report-view="{"spm":"1000.2115.3001.5950","dest":"https://live.csdn.net/room/m0_46700908/rBYvnVNY","extra":"{\"fId\":558,\"fName\":\"floor-www-index\",\"compName\":\"www-home-silde\",\"compDataId\":\"index_live_video_elite_list\",\"fTitle\":\"\",\"pageId\":141,\"utm_medium\":\"distribute.pc_feed_video_elite.none-task-liveroom-csdn#pc_feed_video_elite#liveroom-1-rBYvnVNY-null-null.nonecase\",\"dist_request_id\":\"1655186119224_44062\"}"}"data-v-34c9c026><divclass="www_live_item_top"data-v-34c9c026><divclass="img"style="background-image:url(https://live-file.csdnimg.cn/release/live/file/1654672189981.png?x-oss-process=image/resize,l_1000);"data-v-34c9c026></div><imgsrc="https://csdnimg.cn/release/cmsfe/public/img/nowlive.480a0975.gif"altclass="live-type"data-v-34c9c026><!----><!----><spanclass="live-text"data-v-34c9c026>正在直播</span><divclass="back"data-v-34c9c026></div><!----><divclass="hover_mask"data-v-34c9c026><imgsrc="https://csdnimg.cn/release/cmsfe/public/img/play.9956ea53.png"altdata-v-34c9c026></div></div><divclass="content-text"data-v-34c9c026><h3data-v-34c9c026>
CSDN云原生系列在线峰会:Serverless峰会
</h3><!----><spanclass="text"data-v-34c9c026>690 热度</span></div></a></div><divclass="www_live_item active"data-v-34c9c026data-v-6ebf2afa><a href="https://live.csdn.net/room/MicrosoftReactor/fld1I524" data-report-query="utm_medium=distribute.pc_feed_video_elite.none-task-subscribe-liveroom-csdn#pc_feed_video_elite#subscribe-liveroom-2-fld1I524-null-null.nonecase&depth_1-utm_source=distribute.pc_feed_video_elite.none-task-subscribe-liveroom-csdn#pc_feed_video_elite#subscribe-liveroom-2-fld1I524-null-null.nonecase&spm=1000.2115.3001.5950" data-report-
这就是我们抓取的
CSND
首页的响应信息,我们仔细一看这不就是
CSND
页面的
HTML
确实如此,你请求内容就是为了访问这个网页,所以自然而然返回一个
html
网页!
请求
我们再通过请求协议报格式对刚刚抓取的协议请求进行对比学习!
- 请求行
GET https://www.csdn.net/ HTTP/1.1
- Method
GET
这里的Method
就是http
采取的请求方法! HTTP协议针对不同的请求或者响应可以通过不同的方法进行传输. 上表就是HTTP
协议数据传输可以采取的方法! 每种方法对应不同的应用场景! 例如:我们这里抓取的的GET
方法通常情况下就是为了获取一个资源,我们就是为了获取CSDN
的主页面! 但是这里的方法随着时间的推移,都混用,已经没有上表中的限制了,很多方法丧失了他本来的特性 现在大部分程序员在大部分场景中都习惯于GET
和POST
而且经常两个混用!
- URL
https://www.csdn.net/
URL就是资源唯一标准限定符,就是标志了一个资源具体的网络中的位置!URL
基本格式
- 协议方案名 这里的
HTTPS://
就是协议类型方案名! 就比如我们之前学的数据库编程中的jdbc:mysql
一样!- 登入信息(认证) 这是请求的
URL
这里一般是用户的登入信息,现在的URL
舍去了这部分内容!- 服务器地址
www.csdn.net
就是CSDN
网站服务器地址- 服务器端口号 这里的服务器端口号就和我们所学的五元组中的端口号一样! 这里也一般省略! 因为不同的协议类型它有固定的端口号!
HTTP
协议默认端口号是80``````HTTPS
协议的默认端口号是443
但我们加上这个端口号浏览器也能访问!所以直接省略了这个端口号!- 带层次的文件路径 这里的路径就指出了我们请求要拿的资源在主机中的位置! 这个路径可能是主机磁盘的真实路径也可能是虚拟的由服务器代码动态构造的路径下的资源!
- 查询字符串(query string) 这里的查询字符串一般由键值对的形式构成!
https://editor.csdn.net/md?not_checkout=1&articleId=125276146
比如我们现在写博客的这个网页的URL
这里的查询字符串,就是not_checkout=1&articleId=125276146
键值之间用=
连接 键值对之间用&
分割! 然后查询字符串和文件路径用?
分割! 注意:这里的查询字符串完全是由设计该协议的程序员编写的,具体每个键值对代表的内容信息咱也看不懂!- 片段标识符 描述了当前访问的内容是属于当前这个
HTML
的那个子部分,就例如书签一样,可以直接定位我们之前浏览过的地方!
- Version Version就是HTTP协议的版本号! 这里是
HTTP/1.1
就代表当前的http
协议使用的1.1版本! 现在的版本号有10/1.1/2.0/3.0
而最常用的版本号就是1.1
版本!
- 请求报头
像上述这些都是请求报头的内容,这里的请求报头是键值对的格式!
键和值之间用:
分割开!
键值对之间用;
分割开!
- 空行
空行为了分割请求报头和请求正文!
- 请求正文
请求正文,有的请求协议报文含有这个正文信息,也可以没有正文信息!
***这里的
Query String
有一些需要注意问题***
urlencode
将查询字符串中的值转义!
因为我们知道这里的
URL
有许多字符含有特殊意义,
?
分割文件路径和查询字符串
&
分割键值对等等…所以有些字符就需要通过转移,避免URL无法解析!还有这里的查询字符串不能使用中文,使用中文字符也需要通过urlencode转义!
urlencode规则
我们通过
ASCII
码进行转义!
比如我们需要搜索
C++
https://www.baidu.com/baidu?tn=monline_4_dg&ie=utf-8&wd=C%2B%2B
得到的查询字符串是
C%2B%2B
这就是查询的C++!
因为
+
在
ASCII
码表对应的16进制数据就是2B
然后再在前面加上
%
即可完成转义!
那我们如果要写一个查询字符串,然后又要对照
ASCII
码表那得多麻烦!
我们可以通过现成的在线网站进行
url encode
我们可以
urlencode
也能将已经进行了转义的字符进行
urldecode
还原!
响应
- 状态栏
HTTP/1.1 200 OK
- version 就是这个响应的HTTP版本
- 状态码 描述这个请求的响应结果是否请求成功,或者失败! 一般由一些数字构成,每个数字有特殊的意义,我们后面进行学习!
- 状态码描述 就是告诉我们这个状态码具体描述是什么,请求成功了还是失败!
- 响应报头
响应报文也是由键值对构成,描述了该协议的一些重要信息!
- 空行
分割响应报头和响应正文
- 响应正文
响应正文,就是根据这个请求服务器给出的响应内容,这里是一个HTML网页!
HTTP方法
我们刚刚了解到
HTTP
方法有如上几种
当时由于某些原因,大部分程序员都不会按照上述方法设计的方式,进行使用!
现在都是
GET
和
POST
使用的最为广泛,并且两者混用!
也是就是说
GET
能做的
POST
也可以完成,反正也是如此!
我们找两个来对比一下:
我们的
GET
将请求的信息保存在
querystring
查询字符串中!
而
POST
方法并没有使用
querystring
,采用的是
body
去传输一下数据信息!如下所示
***那
GET
方法和
POST
方法有啥区别呢?***
- 这两个方法没有本质区别,使用的场景都可以混用!
- 语义上,GET是用来取数据获取资源的,POST是用来传数据,传输资源的
- 通常情况下,GET方法是没有body,要通过
querystring
向服务器传输信息,POST方法是没有querystring的需要通过body
传输数据信息!这里指的是通常情况,你也可以给GET搞个body,POST搞个querystring!- GET方法请求一般是幂等的,POST一般是不幂等的(建议这样) 幂等就是说每次输入得到的数据是确定的,不幂等就是对结果不确定!
- GET可以被缓存,POST不能被缓存!因为GET是幂等得到的数据时确定的就可以将结果缓存,如果下次请求直接拿缓存数据就好了! 就比如一个网页如果不论谁访问,什么时间访问得到的结果都是一样的那就是可以被缓存!
版权归原作者 bug 郭 所有, 如有侵权,请联系我们删除。