The difference between Http Post and Get methods

1. Different usage scenarios

get, post, put, delete, respectively correspond to the query, modification, addition, and deletion of resources, and the meaning of the other methods:
OPTIONS returns the HTTP method supported by the server.
CONNECT converts the requested connection to a transparent TCP/IP channel.
HEAD is the same as GET, but only returns the HTTP header, not the body of the document.

2. Idempotence is not the same.

Idempotence is a mathematical concept, and the result of each operation of idempotence is the same.
get is idempotent, the resource has not changed.
Post corresponds to modification operations, so post is not idempotent.
So correspondingly:

3. Get can cache and save, and rewind/refresh has no effect, post cannot.

4. The length, code, and data type of the parameters are different.

Because the get parameter is placed in the URL, the browser limits the URL to 2k for efficiency, and the post is an obvious limit.
get: encoding type application/x-www-form-urlencoded
post: application/x-www-form-urlencoded or multipart/form-data. Use multiple encodings for binary data.
get: Only ASCII characters are allowed.
post: No limit. Binary data is also allowed.

5. The parameter visibility and security of get and post are different.

The get parameter is placed in the url, and the history record is visible, which is not safe.
In fact, the post is also unsafe and can be obtained by capturing the packet.
The secure protocol is https.

6. GET generates one TCP data packet; POST generates two TCP data packets.

For GET requests, the browser will send the http header and data together, and the server will respond with 200 and return the data;

For POST, the browser first sends the header, the server responds with 100 continue, the browser sends data, and the server responds with 200 ok to return the data.

Guess you like

Origin blog.csdn.net/u010321471/article/details/108479860