标签:
http信息分三部分
1.请求行
GET lizi.php HTTP/1.1
2.HTTP头信
Host: localhost Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36
Referer: http://localhost/lizi.html
Accept-Encoding: gzip, deflate, sdch
Accept-Language: zh-CN,zh;q=0.8,en;q=0.6
Cookie: name=kang
RA-Ver: 2.10.3
RA-Sid: DCB4EFBD-20140418-043349-b3d8d4-8da4c7
3.内容
。。。。。。。
注意:get请求方式时,是没有内容的,因为他把内容放到了url中,post是有的,因此也可以说get不符合规范
重点说http头信息
头可以说是一个大杂烩仓库,用于客户端和服务端进行交互信息,也就是说头信息中的字段可以自定义,添加任何样的都不会有影响
在客户端浏览器中,cookie是会被放到头中发送给客户端,这是浏览器放置的,咱也可以模拟放置其他信息
例子:
1 $head = array( 2 "Host: localhost", 3 "Connection: keep-alive", 4 "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 5 User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36", 6 "Referer: http://localhost/lizi.html", 7 "Accept-Encoding: gzip, deflate, sdch", 8 "Accept-Language: zh-CN,zh;q=0.8,en;q=0.6", 9 "Cookie: name3=kang", 10 "demo:demo", 11 "RA-Ver: 2.10.3", 12 "RA-Sid: DCB4EFBD-20140418-043349-b3d8d4-8da4c7", 13 );
这个头可以用curl发送
在中间随意插入了并未有的cookie和demo字段,在服务端打印$_SERVER是可以完全接受到的
‘HTTP_HOST‘ =>
string
‘localhost‘ (length=9) ‘HTTP_CONNECTION‘ =>
string
‘keep-alive‘ (length=10) ‘HTTP_ACCEPT‘ =>
string
‘text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36‘ (length=194) ‘HTTP_REFERER‘ =>
string
‘http://localhost/lizi.html‘ (length=26) ‘HTTP_ACCEPT_ENCODING‘ =>
string
‘gzip, deflate, sdch‘ (length=19) ‘HTTP_ACCEPT_LANGUAGE‘ =>
string
‘zh-CN,zh;q=0.8,en;q=0.6‘ (length=23) ‘HTTP_COOKIE‘ =>
string
‘name3=kang‘ (length=10) ‘HTTP_DEMO‘ =>
string
‘demo‘ (length=4) ‘HTTP_RA_VER‘ =>
string
‘2.10.3‘ (length=6) ‘HTTP_RA_SID‘ =>
string
‘DCB4EFBD-20140418-043349-b3d8d4-8da4c7‘ (length=38)
标签:
原文地址:http://www.cnblogs.com/hanyouchun/p/4505040.html