GET
It requests a resource at the request URL. It should not contain a request body as it will be discarded. May be it can be cached locally or on the server.
- GET 获取信息 get是safe的
- 从一个具体的resource 获取数据
- 额外的参数信息都在url里面
- 我们可以bookmark GET请求
- 我们应该只在获取信息的时候使用GET
- 我们在写爬虫的时候一般使用get和head
get的参数在哪?
get的query string 或者说name/value pairs 存在于url中
/test/demo_form.php?name1=value1&name2=value2
POST 创建数据 post,是unsafe的,多次post,服务器可能会创建多个resource
- It submits information to the service for processing;
- it should typically return the modified or new resource;
post的参数在哪?
post的query string 或者说name/value pairs 存在于http message body
POST /test/demo_form.php HTTP/1.1
Host: w3schools.com
name1=value1&name2=value2
<method> <request-URL> <version>
<headers>
<entity-body>
所以再问post body在哪,可以回答在header的后面~
extra bonus
application/json
POST http://www.example.com HTTP/1.1
Content-Type: application/json;charset=utf-8
{"title":"test","sub":[1,2,3]}
上面这个json 也是在header后面,这个header里面包含了content-type信息和charset编码信息