Such as the difference between GET POST PUT request method

 
————————

1, PUT and POST difference

POS PUT and semantics specified URI has changed but is defined PUT method is a method retries genuinely idempotent (power, etc.), POST is not .idempotent of:

If a method is repeated multiple times, the effect is the same, and that is the idempotent.

In other words:

PUT request: if two requests are identical, the request is a first request will be overwritten. (So ​​to change resources PUT)

Post request: a request after the first request will not be overwritten. (So ​​Post to increase resources)

2, GET and POST difference

1, parameter passing mode: GET passed through the URL, POST Request body in place.

2, cache policy parameters: GET request will be actively cache browser, POST will not, unless manually. GET request parameters are intact in the browser history, and the POST parameters will not be retained.

3, the parameter transcode: Get request has non-ASCII characters will be transcoded before the request, not POST, POST because the Request body by MIME, also can transfer non-ASCII characters.

4, the general browser enter the URL to access Web sites are GET request

5, the size limit parameters: HTTP is the underlying TCP / IP. HTTP is just a code of conduct, while TCP is GET and POST how to achieve basic. GET / POST is a TCP connection. GET and POST can do the same. But the amount of data requested is too large for the browser and the server is a great burden. So the industry has unwritten rules, (most) browsers usually limit url 2K bytes in length, and (most of) the size of the server process up to 64K url.

6, the process request: GET generating a TCP packet; generating the POST two TCP packets. For the GET request, the browser will http header and data sent together, the server response 200 (return data); for the POST, the browser transmits the first header, the server response 100 continue, the browser then transmits data, in response to the server 200 ok (return data). In the network environment is good, send a packet and a time difference between the time sent two packets can be basically ignored. And in the case of poor network environment, TCP packets over the two packet integrity verification, there is great advantage. But not all browsers will send two packets during POST, Firefox is sent only once.

————————

http post and get methods of popular interpretation

Create a new record, just use post,
update a record on the use of words put.

————————

POST is used to submit the data. The data submitted in the body of the HTTP request, the object is to submit data and for storing the server without allowing the user to change too much the corresponding data (mainly with respect to a lot of trouble to modify the url).
PUT operation is idempotent. The so-called idempotent means that no matter how many operations, the results are the same. For example, I used to modify PUT an article, and then doing the same operation, the result of each operation is no different.

POST operation is neither safe nor idempotent, such as common POST repeated loading problem: When we sent the same POST request multiple times, the result is to create a number of resources.

Meaning safe and idempotent that: when the operation does not achieve the desired objectives, we can not stop retried without resources have side effects. In this sense, POST operations tend to be harmful, but often still have to use it.

Another point to note is that you can use to create operations POST, PUT can be used, the difference is that POST action on a set of resources (/ articles), and PUT operations are in effect on a specific resource (/ articles / 123),
then popular point that, if the URL can be determined at the client, then use PUT, if it is determined at the server, then use POST,
for example, a lot of resources using a database auto-increment primary key as identification information, and create identification information of resources in the end what can only be provided by the server, this time it must use POST.

 

Guess you like

Origin www.cnblogs.com/createtable/p/11068929.html