[infinispan-issues] [JBoss JIRA] Commented: (ISPN-304) REST API should not use POST
Manik Surtani (JIRA)
jira-events at lists.jboss.org
Tue Mar 9 10:04:00 EST 2010
[ https://jira.jboss.org/jira/browse/ISPN-304?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12518942#action_12518942 ]
Manik Surtani commented on ISPN-304:
------------------------------------
I am able to post - http://groups.google.com/group/reststar-caching/browse_thread/thread/57d00b9caf7a3240
Perhaps you didn't post as michael.neale at gmail.com (which is what you are registered on the list as)?
> REST API should not use POST
> ----------------------------
>
> Key: ISPN-304
> URL: https://jira.jboss.org/jira/browse/ISPN-304
> Project: Infinispan
> Issue Type: Bug
> Components: Cache Server
> Affects Versions: 4.0.0.CR2, 4.0.0.Final
> Reporter: Jozef Hartinger
> Assignee: Michael Neale
> Priority: Optional
> Fix For: 4.1.0.ALPHA2, 4.1.0.Final
>
>
> Currently, the REST API provided by Infinispan uses POST for creating new resources, for example:
> POST to /infinispan/rest/data/foo containing "bar" will create a new key-value pair (foo, bar)
> However, the HTTP spec says that POST should be used for creating *subordinate* resources, which is not done in this case because the resource itself is created and not a subordinate one.
> Moreover, the RESTful Web Services book which is kind of a bible for writting RESTful applications claims that the POST method can be used for creating resources *only if the server is in charge of choosing the URI for a new resource* (for example if a POST sent to /infinispan/rest/data would cause server to choose a key for the given value and make it available under /infinispan/rest/data/choosenKey). In contrast, if the *client is responsible for creating the URI* (which is the case of Infinispan), the client should use a PUT sent to the chosen URI (PUT /infinispan/rest/data/foo) to create the resource. That means that there is no difference between the initial creation of a resource and a subsequent update (both request are PUT requests to the same URI) - fits exactly how cache.put() works.
> The downside of this approach is that the client does not get 409 when he/she wants to create an explicitly new resource and a resource with that key exists already. Nevertheless, if this behavior is really needed, it can be achieved alternatively, for example by introducing a path parameter "overwrite" which if set to "false" and the resource already exists, will cause the server to return 409.
> To summarize, IMHO it would be cleaner to stop using POST for creating new cache records and use PUT for this purpose instead.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the infinispan-issues
mailing list