第二节 telnet模拟get和post方法

来源:互联网 发布:淘宝如何进入卖家中心 编辑:程序博客网 时间:2024/05/16 05:33

一.模拟get方法

1.window下

cmd –>telnet 主机地址 80

2.linux下

telnet 主机地址 80

3.按下快捷键:Ctrl+’ ] ‘再按下回车

4.发送请求报文

GET /http/demo1.php HTTP/1.1 Host:localhost  空行 回车

5.回复

HTTP/1.1 200 OKDate: Thu, 08 Dec 2016 03:37:44 GMTServer: Apache/2.4.18 (Ubuntu)Content-Length: 5Content-Type: text/html; charset=UTF-8空行demo1

6.解析

GET(请求方法) /http/demo1.php(请求的URL) HTTP/1.1(http协议版本)-->请求行Host:localhost(请求首部)(空行)HTTP/1.1 200(相应结果状态码) OK(状态描述)Date: Thu, 08 Dec 2016 03:37:44 GMTServer: Apache/2.4.18 (Ubuntu)(服务器信息)Content-Length: 5(回复内容一共5字节)Content-Type: text/html; charset=UTF-8(格式,字符)demo1(回复内容)

2.post方法

发送

POST /http/demo1.php HTTP/1.1HOST:localhostContent-type:application/x-www-form-urlencodedcontent-length:20空行act=query&name=ghost

回复

HTTP/1.1 200 OKDate: Thu, 08 Dec 2016 03:54:01 GMTServer: Apache/2.4.18 (Ubuntu)Content-Length: 11Content-Type: text/html; charset=UTF-8空行queryghost
0 0
原创粉丝点击