http協議內容展示以及如何用telnet發送請求


1.http協議組成:

  報文首部:狀態行(請求行) 請求首部字段 通用字段 其他信息

  空行

  報文主體

GET請求頭:
GET /test.php?a=1 HTTP/1.1
Host: localhost
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/54.0.2840.99 Safari/537.36
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
POST請求頭:
POST /test.php HTTP/1.1
Host: localhost
Connection: keep-alive
Content-Length: 42
Cache-Control: max-age=0
Origin: http://localhost
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Referer: http://localhost/test.php
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.8

2.在命令行下用telnet模擬發送get或post請求

  1.cmd
  2.telnet localhost 80
  3.先同時按下"ctrl + ]" 用於回顯內容,再按下"回車鍵"
  4.黏貼請求頭
  
GET請求頭:
GET /test.php?a=1 HTTP/1.1
HOST:localhost

POST請求頭:
POST /test.php HTTP/1.1
HOST:localhost
Content-Length:7 // 必須加上這個頭
Content-type:application/x-www-form-urlencoded

name=ht // 在上面的請求頭黏貼完畢后,回車兩次,再輸入

// get請求頭黏貼后,回車兩次,顯示請求內容;post請求頭,黏貼完畢后,回車,輸入post請求參數字符串,自動顯示請求內容

 

  
                    


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM