ArchTiger MYPI

ArchTiger
접속 : 3075   Lv. 51

Category

Profile

Counter

  • 오늘 : 20 명
  • 전체 : 10886 명
  • Mypi Ver. 0.3.1 β
[프로그래밍] Idempotent and POST and PUT Method (0) 2011/10/20 PM 02:59
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.

신고

 
X