1. 程式人生 > >二、web通訊

二、web通訊

	·URL:
		·Uniform Resource Locator	統一資源定位符
		·作用:定位伺服器資源(收貨地址)
		·URL的詳細格式
			·schema://host[:port#]/path/.../[?query-string][#anchor]
				·schema:底層協議(例如:http,https,ftp)
				·host:伺服器的域名或者IP地址
				·port:伺服器的埠,HTTP預設埠是80(可省略),其他埠要指明
				·path:訪問資源的路徑
				·query-string:傳送給http伺服器的資料
				·anchor:錨點,表示在頁面的特定位置
			·example
			http:
//dun.163.com/sj/test/test.jsp?name=sviergn&x=true#stuff schema:http host:dun.163.com port:沒有寫,預設是80 path:sj/test/test.jsp query-string:name=sviergn&x=true anchor:stuff ·HTTP: ·Hyper Text Transfer Protocol 超文字傳輸協議 ·是Web通訊時使用的協議 ·Web的基礎 ·什麼是HTTP協議 ·送貨人:快遞小哥 ==>
瀏覽器 ·方式:汽車 ==> Get、Post、...... ·收件人地址:浙江省杭州市濱江區 ==>Host ·快遞公司:某某快遞 ==>User-Agent ·公司通行證:通行證 ==>Cookie ·簽收狀態:已簽收 ==>Response:HTTP 200 +正文,其中200表示正常收到 ·HTTP的報文: ·請求報文 ·請求行 ·頭部 ·(cookies) 盜取cookie的安全漏洞 ·空行 ·資料體 ·響應報文 ·狀態行 ·訊息報頭 ·空行 ·響應正文 ·HTTP請求--
-其他請求方式 ·HEAD:與GET請求類似,不同在於伺服器只返回HTTP頭部資訊,沒有頁面內容 ·PUT:上傳指定URL的描述 ·DELETE:刪除指定資源 ·OPTIONS:返回伺服器支援的HTTP方法 ·HTTP請求---Referer ·告知伺服器該請求的來源(瀏覽器自動加上) ·統計流量 ·CNZZ ·百度統計 ·判斷來源合法性 ·防止盜鏈(此圖片來自QQ空間,未經允許不可引用) ·防止CSRF漏洞 實戰: Google 開發者工具 Network all 88個請求 status全部是200,表示正常收到 DOC 看到返回碼是200 點到Headers ·看到響應頭和請求頭 ·Request Header檢視原始碼:view parsed GET / HTTP/1.1 Host: dun.163.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/70.0.3538.110 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.9 Cookie: __f_=1544852246824; _ntes_nnid=e9eeb140628c00705c2821052b21d527,1544852246937; _ntes_nuid=e9eeb140628c00705c2821052b21d527; NTES_YD_PASSPORT=COxHyuBVDRNP_vnRUIofX6bTrmeB7N0yJY_AvuC2Jpz4rOhUrIJ5LfcR.F_AyQRWwuVoU_vN2Aa6270P4x7nrDH3kojqPBxDdFKprCOTzX7XLwjOMh61HMoebBsyluXrFw6Plleu.8CpN2R0Dr3OAs016Nb_9cSb_uPWpAu6b4ZnPuvb.jU4HJNwjikacmEt3xiWYAKfZsrpf; [email protected]|1544871550|0|mail163|00&99|shh&1544234478&mail163#shh&null#10#0#0|151481&0|mailmaster_android&mail163&mail163_qrcode|[email protected]; NNSSPID=6f55d35753984fce8a2008b5bd706eaf; mail_psc_fingerprint=9fd5e21e2dbea2a6eb13aa3822246319; usertrack=CrHud1wU3oNDzuLjA0DuAg==; Province=021; City=021; NTES_hp_textlink1=old; UM_distinctid=167b4f24be563a-07f5ddb5df4fb9-3f674706-1fa400-167b4f24be61b0; _ga=GA1.2.1439639983.1544932352; _gid=GA1.2.1352615126.1544932352; Hm_lvt_4671c5d502135636b837050ec6d716ce=1544932353,1544936844; Hm_lpvt_4671c5d502135636b837050ec6d716ce=1544938581 dun.163.com ·Response Header檢視原始碼:view parsed HTTP/1.1 200 OK Server: nginx Date: Sun, 16 Dec 2018 05:36:44 GMT Content-Type: text/html; charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive Vary: Accept-Encoding x-xss-protection: 1; mode=block x-content-type-options: nosniff x-download-options: noopen x-readtime: 1 Content-Encoding: gzip ·DOC-Response-響應的結構體 ·Cookies ·Timing

報文:在這裡插入圖片描述