1、HTTP头信息
request line 请求类型、访问资源、http版本
headers http头消息
\r\n
request body 任意其他数据body
Get请求样例:
GET /test?name=jack&password=123456 HTTP/1.1
Host: www.gotest.com
Connection: Keep-Alive
Post请求样例:
POST /test HTTP/1.1
Host: www.gotest.com
Connection: Keep-Alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 40
Connection: Keep-Alive
\r\n
name=jack&password=123456
2、Get和Post区别
Get主要从服务器上获取数据;Post主要向服务器传送数据;
Get使用request.URL.RawQuery获取参数;Post使用request.FormValue("key")获取参数;
由于安全问题,尽量使用Post提交表单。