GET和POST的请求方式比较

GET/POST都是TCP链接

所以, GET和POST能做的事情是一样一样的. 可以给GET加上request body,给POST带上url参数

RFC7231

      +---------+-------------------------------------------------+-------+
   | Method  | Description                                     | Sec.  |
   +---------+-------------------------------------------------+-------+
   | GET     | Transfer a current representation of the target | 4.3.1 |
   |         | resource.                                       |       |
   | HEAD    | Same as GET, but only transfer the status line  | 4.3.2 |
   |         | and header section.                             |       |
   | POST    | Perform resource-specific processing on the     | 4.3.3 |
   |         | request payload.                                |       |
   | PUT     | Replace all current representations of the      | 4.3.4 |
   |         | target resource with the request payload.       |       |
   | DELETE  | Remove all current representations of the       | 4.3.5 |
   |         | target resource.                                |       |
   | CONNECT | Establish a tunnel to the server identified by  | 4.3.6 |
   |         | the target resource.                            |       |
   | OPTIONS | Describe the communication options for the      | 4.3.7 |
   |         | target resource.                                |       |
   | TRACE   | Perform a message loop-back test along the path | 4.3.8 |
   |         | to the target resource.                         |       |
   +---------+-------------------------------------------------+-------+

都可以传递三种content-typebody数据

CONTENT_TYPE    application/json
CONTENT_TYPE    x-www-form-urlencoded
CONTENT_TYPE    form-data 

注意 有些web服务器会直接忽略get的请求体

GET vs POST区别

语义不同

POST

目标资源根据资源自身的特定语义来处理请求中包含的需求

The POST method requests that the target resource process the representation enclosed in the request according to the resource’s own specific semantics.

GET

通过 URI, 来识别资源

The GET method requests transfer of a current selected representation for the target resource.

参考»>https://zhuanlan.zhihu.com/p/25028045

Buy me a 肥仔水!