Web协议详解与抓包实战:HTTP1协议-内容协商是怎样进行的(8)
一、内容协商的两种方式
每个 URI 指向的资源可以是任何事物,可以有多种不同的表述,例如一份文档可以有不同语言的翻译、不同的媒体格式、可以针对不同的浏览器提
供不同的压缩编码等
二、Proactive 主动式内容协商
三、Reactive 响应式内容协商
四、常见的协商要素
1、常见协商要素1
2、常见协商要素2
内容编码:主要指压缩算法
响应中的压缩方式
五、国际化与本地化
六、资源表述的元数据头部
六、cURL工具使用
1、--compressed 将结果解压缩
命令
curl 'https://www.baidu.com/' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: zh-CN,zh;q=0.9' -H 'Cookie: BDUSS=Y3Ty0zbFdRbTBIWWdlZ0UtRjZpOGNzdFFtVXVzNTJiemxXNzdyc1lNak45ZkJjSVFBQUFBJCQAAAAAAAAAAAEAAACumLcCbHVvYWhvbmcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM1oyVzNaMlcRH; A^`=1570252928jMyG000154233; BAIDUID=D3466420B11AEE8C6DCE1776E360E57C:FG=1; PSTM=1570252049; BIDUPSID=9ED37D1EFAB864BCB9197CD7637AB8CC; BD_UPN=12314353; BDORZ=FFFB88E999055A3F8A630C64834BD6D0; H_PS_645EC=a521LDhJX1l%2BFB6jUNwQI7xetFq3k3%2FLeU6yK%2Fb70nZrV8c%2B%2FpIMx8OkrgfHWtqdpDC8; BD_HOME=1; H_PS_PSSID=1430_21124_29522_29720_29568_29220; sugstore=1' --compressed
运行结果
bds.comm.dpquery=""; bds.comm.samSugApi=s_session.sid === "25219" ? 1 : 0; var index_content = $('#head'); var index_foot= $('#ftCon'); var index_css= $('#style_super_inline'); var index_is_css = $('#s_is_index_css'); var index_css_content = index_css.html(); var index_u= $('#u_sp'); var result_u= $('#u'); window.index_links = []; var result_head = $("#head"); window.index_on=function(){ s_session.index_off = false; }; window.index_off=function(){ s_session.index_off = true; $(document.body).attr('link', '#0000cc'); index_links = []; $("head").find("link").each(function(){ index_links.push(this); $(this).remove(); }); index_css.remove(); index_is_css.remove(); $('#head_wrapper').css('width',''); $('#kw').css('font-family',''); $('head').append($.decodeHTML($('#s_index_off_css').html())); $('head').append($.decodeHTML($('#s_is_result_css').html())); $('.s-tips-skin').remove(); $('.s-skin-container').remove(); $('#s_mancard_newmusic').remove(); };
2、去掉--compressed 结果是二进制文件
curl 'https://www.baidu.com/' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: zh-CN,zh;q=0.9' -H 'Cookie: BDUSS=Y3Ty0zbFdRbTBIWWdlZ0UtRjZpOGNzdFFtVXVzNTJiemxXNzdyc1lNak45ZkJjSVFBQUFBJCQAAAAAAAAAAAEAAACumLcCbHVvYWhvbmcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM1oyVzNaMlcRH; A^`=1570252928jMyG000154233; BAIDUID=D3466420B11AEE8C6DCE1776E360E57C:FG=1; PSTM=1570252049; BIDUPSID=9ED37D1EFAB864BCB9197CD7637AB8CC; BD_UPN=12314353; BDORZ=FFFB88E999055A3F8A630C64834BD6D0; H_PS_645EC=a521LDhJX1l%2BFB6jUNwQI7xetFq3k3%2FLeU6yK%2Fb70nZrV8c%2B%2FpIMx8OkrgfHWtqdpDC8; BD_HOME=1; H_PS_PSSID=1430_21124_29522_29720_29568_29220; sugstore=1'
截图如下
3、去掉头部的压缩-H 'Accept-Encoding: gzip, deflate, br'
作者:罗阿红
出处:http://www.cnblogs.com/luoahong/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。