The difference between get and post

The difference between get and post

1. For GET requests, the requested data will be appended to the URL, and the URL and transmission data will be divided by ?, and multiple parameters will be connected with &. The URL encoding format uses ASCII encoding instead of uniclde, which means that all non-ASCII characters must be encoded before transmission.

POST request: POST request will place the requested data in the body of the HTTP request packet. The above item=bandsaw is the actual transmission data.

Therefore, GET request data will be exposed in the address bar, but POST request will not.

2. The size of the transmitted data

In the HTTP specification, there are no restrictions on the length of the URL and the size of the transmitted data. But in the actual development process, for GET, specific browsers and servers have restrictions on the length of the URL. Therefore, when using a GET request, the transmitted data will be limited by the length of the URL.

For POST, since it is not a URL to pass a value, it is theoretically not restricted, but in fact, each server will stipulate a limit on the size of POST submitted data. Apache and IIS have their own configurations.

3. Security

The security of POST is higher than that of GET. The security here refers to the real security, and different from the security in the security method mentioned above GET, the security mentioned above is just not to modify the server's data. For example, during a login operation, through a GET request, the user name and password will be exposed on the URL, because the login page may be cached by the browser and other people may view the history of the browser. At this time, the user name and password are easy It was taken by someone else. In addition, the data submitted by the GET request may also cause a Cross-site request frogery attack

Guess you like

Origin blog.csdn.net/weixin_43515837/article/details/112141444