HTTP协议中GET和POST区别

  • GET一般用于获取和查询资源信息;POST一般用于更新信息,表示可能修改服务器上资源的请求
  • GET请求一般是幂等的
  • GET请求数据会附加在url之后,POST请求数据放到request-body中
  • GET请求,Http协议规范没有对url长度进行限制,不同的浏览器限制不同,IE为2083,因此导致对GET请求有长度限制
  • POST请求,Http协议中没有大小限制,限制往往在IIS、服务器等,不同的环境不同的限制
  • 安全性,GET请求数据明文体现在url上,可以被浏览器缓存,显得不那么安全。其实,通过工具GET和POST请求信息都是可以查看的,理论上不加密,都不安全,所以出现了Https...

GET头:

GET /hello/checkUser.html?username=yyy&age=zzz HTTP/1.1
Referer: http://localhost:8000/hello/index.html
Accept: */*
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
Host: localhost:8000
Connection: Keep-Alive
Cookie: JSESSIONID=BBBA54D519F7A320A54211F0107F5EA6

POST头:

POST /hello/checkUser.html?opt=xxx HTTP/1.1
Referer: http://localhost:8000/hello/index.html
Accept: */*
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Host: localhost:8000
Content-Length: 20
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: JSESSIONID=BBBA54D519F7A320A54211F0107F5EA6
username=yyy&age=zzz

参考1
参考2

posted @ 2017-10-26 09:54  toto怎么会喝醉  阅读(197)  评论(0编辑  收藏  举报