The difference between patch and put methods

patchThe method used to update the local resources

Suppose there is a UserInfo, there userId, userName, userGender other 10 fields. Programmable function because of demand, at some particular pages can only be modified userName. Usually it contains a modified full userInfo userName objects passed to the back-end, do a full update, this approach will waste broadband. Thus patchwas born, only one pass userNameto the specified resource to indicate that the request is a partial update, only the rear field of the received updates.

And putalthough it has also updated resource, but requires front end offers must be a complete resource object, in theory, if used put, but did not provide a complete UserInfo, then the missing of those fields should be cleared.

If you did not follow the standard procedure to do the back-end processing of two different methods, the method name in the program from putchangepatchm没有任何影响。

An important difference between the PATCH and PUT property lies: PUT is idempotent, rather than PATCH idempotent (represents an operation performed any number of times the impact on the system with the same time) is.

POST method is not idempotent, if repeated every time a new resource is created multiple times corresponding. If the request times out, the need to answer the question: whether the resource has been created on the server? Then you can try again or check the list of resources? For there is no power other methods to this problem, we can safely repeated requests.

 

Original: https://blog.csdn.net/varyall/article/details/80895945

Guess you like

Origin www.cnblogs.com/xjy20170907/p/11647585.html