• [프로그래밍] Idempotent and POST and PUT Method2011.10.20 PM 02:59

게시물 주소 FONT글자 작게하기 글자 키우기

Describing an action which, when performed multiple times, has no further effect on its subject after the first time it is performed.

According to HTTP 1.1 specifications

"The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line" i.e. Create.

" The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. If the Request-URI does not point to an existing resource, and that URI is capable of being defined as a new resource by the requesting user agent, the origin server can create the resource with that URI." That is, a Create or an Update.

Railes example
- Use POST to create a group, and PUT to update the members of it.
POST /items #=> create
PUT /items/1 #=> update

Atom Publication Protocol (AtomPub) specification
To add members to a Collection, clients send POST requests to the URI of the Collection.

Yes!, there is an argue between PUT and POST but generally
POST for creation, PUT for updates are reasonable. also avoid POST method without body.
댓글 : 0 개
친구글 비밀글 댓글 쓰기

user error : Error. B.