19 |
19 |
# 02110-1301, USA.
|
20 |
20 |
|
21 |
21 |
|
22 |
|
"""Remote API version 2 baserlib.library.
|
23 |
|
|
24 |
|
PUT or POST?
|
25 |
|
============
|
26 |
|
|
27 |
|
According to RFC2616 the main difference between PUT and POST is that
|
28 |
|
POST can create new resources but PUT can only create the resource the
|
29 |
|
URI was pointing to on the PUT request.
|
30 |
|
|
31 |
|
To be in context of this module for instance creation POST on
|
32 |
|
/2/instances is legitim while PUT would be not, due to it does create a
|
33 |
|
new entity and not just replace /2/instances with it.
|
34 |
|
|
35 |
|
So when adding new methods, if they are operating on the URI entity itself,
|
36 |
|
PUT should be prefered over POST.
|
|
22 |
"""Remote API resource implementations.
|
|
23 |
|
|
24 |
PUT or POST?
|
|
25 |
============
|
|
26 |
|
|
27 |
According to RFC2616 the main difference between PUT and POST is that
|
|
28 |
POST can create new resources but PUT can only create the resource the
|
|
29 |
URI was pointing to on the PUT request.
|
|
30 |
|
|
31 |
In the context of this module POST on ``/2/instances`` to chance an existing
|
|
32 |
entity is legitimate, while PUT would not be. PUT creates a new entity (e.g. a
|
|
33 |
new instance) with a name specified in the request.
|
|
34 |
|
|
35 |
Quoting from RFC2616, section 9.6:
|
|
36 |
|
|
37 |
The fundamental difference between the POST and PUT requests is reflected in
|
|
38 |
the different meaning of the Request-URI. The URI in a POST request
|
|
39 |
identifies the resource that will handle the enclosed entity. That resource
|
|
40 |
might be a data-accepting process, a gateway to some other protocol, or a
|
|
41 |
separate entity that accepts annotations. In contrast, the URI in a PUT
|
|
42 |
request identifies the entity enclosed with the request -- the user agent
|
|
43 |
knows what URI is intended and the server MUST NOT attempt to apply the
|
|
44 |
request to some other resource. If the server desires that the request be
|
|
45 |
applied to a different URI, it MUST send a 301 (Moved Permanently) response;
|
|
46 |
the user agent MAY then make its own decision regarding whether or not to
|
|
47 |
redirect the request.
|
|
48 |
|
|
49 |
So when adding new methods, if they are operating on the URI entity itself,
|
|
50 |
PUT should be prefered over POST.
|
37 |
51 |
|
38 |
52 |
"""
|
39 |
53 |
|