一.模拟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 OK
Date: Thu, 08 Dec 2016 03:37:44 GMT
Server: Apache/2.4.18 (Ubuntu)
Content-Length: 5
Content-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 GMT
Server: 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.1
HOST:localhost
Content-type:application/x-www-form-urlencoded
content-length:20
空行
act=query&name=ghost
回复
HTTP/1.1 200 OK
Date: Thu, 08 Dec 2016 03:54:01 GMT
Server: Apache/2.4.18 (Ubuntu)
Content-Length: 11
Content-Type: text/html; charset=UTF-8
空行
query
ghost