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请求参数字符串,自动显示请求内容

 

  
                    
posted @ 2017-01-26 11:10  涛涛taotao  阅读(2077)  评论(0编辑  收藏  举报