天天看點

HTTP協定簡單介紹

HTTP協定簡單介紹

什麼是http協定

http協定: 對浏覽器用戶端 和 伺服器端 之間資料傳輸的格式規範

檢視http協定的工具

  1. 使用火狐的firebug插件(右鍵->firebug->網絡)
  2. 使用谷歌的“審查元素”
  3. 使用第三方浏覽器(右鍵->審查元素->NetWork)

協定内容

打開工具後,重新整理網頁會有很多資料出現,随便點選一個,在點Headers頁籤(預設),就會看到HTTP請求的内容了。

Request Headers

我們想檢視請求頭吧:Request Headers裡面的内容

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch, br
Accept-Language:zh-CN,zh;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Host:www.csdn.net
Referer:
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.76 Mobile Safari/537.36
           

我們挑選幾個常用也是重要的部分:

Host

代表你所通路的網站位址

User-Agent

浏覽器辨別

其他的可以自行查找百度

Response Headers

有請求,就會有響應,如果沒有響應那麼隻能說明伺服器抛棄了你的請求,或者伺服器沒有收到請求

Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html; charset=UTF-8
Date:Sat, 17 Mar 2018 15:32:00 GMT
Keep-Alive:timeout=20
Server:openresty
Set-Cookie:TINGYUN_DATA=%7B%22xxxxig1WV1dfhs%23gIMN6oMlwr0%22%2x2%3A%222118521c473d4a7%22%2C%22q%22%3A0%2C%22a%22%3A27%7D
Strict-Transport-Security:max-age=864000
Transfer-Encoding:chunked
Vary:Accept-Encoding
X-Powered-By:PHP/5.5.23
           

Content-Encoding

編碼方式

Content-Type

響應内容

Server

伺服器辨別

General

這是最最最常用的

Request URL:
Request Method:GET
Status Code:200 OK
Remote Address:47.95.164.112:443
           

Request URL

辨別目前你通路的内容

Request Method

請求的方法類型

Status

Remote Address

繼續閱讀