| Summary: | RFE: creating buckets/key should return server response '201 Created' | ||
|---|---|---|---|
| Product: | [Retired] CloudForms Cloud Engine | Reporter: | Dave Johnson <dajohnso> |
| Component: | iwhd | Assignee: | Jim Meyering <meyering> |
| Status: | CLOSED CURRENTRELEASE | QA Contact: | Dave Johnson <dajohnso> |
| Severity: | low | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 0.3.1 | CC: | akarol, dajohnso, deltacloud-maint, meyering, ssachdev, whayutin |
| Target Milestone: | rc | Keywords: | FutureFeature |
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Enhancement | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2011-12-08 13:48:53 UTC | Type: | --- |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
I replied with a patch on list: http://thread.gmane.org/gmane.comp.lib.iwhd.devel/534/focus=541 Thanks for the report.
While this is purely a consistency issue (rather than correctness,
as far as I know), I've went ahead and wrote the change and added
a test to exercise it:
>From 28df097fcc95e457a9586ea5e60e51652cea1a19 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@...>
Date: Wed, 27 Apr 2011 13:47:27 +0200
Subject: [PATCH] upon successful bucket or object creation, issue HTTP code
201, not 200
200 is a mere "OK", while 201 is the slightly more descriptive CREATED.
However, note that the 201 response does not guarantee that there
was no prior object by the same name. I.e., if you create an object
and that happens to replace one that already existed, you'll get 201
just as when you create an object in an empty bucket.
This makes the code more consistent: even before this change,
attribute-creation would elicit a 201 response.
* rest.c (proxy_put_data): Use MHD_HTTP_CREATED, not MHD_HTTP_OK.
(create_bucket): Likewise.
* t/creation-code (iwhd_pid): New file. Test for the above.
* t/Makefile.am (TESTS): Add it.
Base on the above comment I.e., if you create an object
and that happens to replace one that already existed, you'll get 201.
Verification details:
creating buckets/key returns server response '201 Created'
# create bucket
[root@ibm-hs22-01 log]# curl --write-out %{http_code} -d name=myBucket http://127.0.0.1:9090/_new
201
# create key
[root@ibm-hs22-01 log]# curl --write-out %{http_code} --request PUT http://127.0.0.1:9090/myBucket/drop1
201
# view created key
[root@ibm-hs22-01 log]# curl --write-out %{http_code} http://127.0.0.1:9090/myBucket
<objects>
<object>
<bucket>myBucket</bucket>
<key>drop1</key>
</object>
</objects>
200
# create attribute
[root@ibm-hs22-01 log]# curl --write-out %{http_code} --request PUT -d 'blue' http://127.0.0.1:9090/myBucket/drop1/color
201
#view created attribute
[root@ibm-hs22-01 log]# curl --write-out %{http_code} http://127.0.0.1:9090/myBucket/drop1/_attrs
<object>
<object_body path="http://127.0.0.1:9090/myBucket/drop1"/>
<object_attr_list path="http://127.0.0.1:9090/myBucket/drop1/_attrs"/>
<object_attr name="color" path="http://127.0.0.1:9090/myBucket/drop1/color"/>
</object>
200
verified on:
[root@ibm-hs22-01 log]# rpm -qa | grep aeolus
aeolus-conductor-daemons-0.3.0-0.el6.20110617144720git2a4555b.noarch
rubygem-aeolus-cli-0.0.1-1.el6.20110617144720git2a4555b.noarch
aeolus-conductor-0.3.0-0.el6.20110617144720git2a4555b.noarch
aeolus-conductor-doc-0.3.0-0.el6.20110617144720git2a4555b.noarch
aeolus-all-0.3.0-0.el6.20110617144720git2a4555b.noarch
aeolus-configure-2.0.1-0.el6.20110602110128git5cb9257.noarch
release pending... release pending... perm close |
Accessing the iwhd REST API and creating buckets and keys, I noticed the server response comes back with '200 OK'. Technically, I believe the proper response should be '201 Created' which is the response received when creating key attributes. # create bucket, notice 200 response [root@ip-10-82-221-216 doc]# curl --write-out %{http_code} -d name=myBucket http://127.0.0.1:9090/_new 200 # create key, notice 200 response [root@ip-10-82-221-216 doc]# curl --write-out %{http_code} --request PUT http://127.0.0.1:9090/myBucket/drop1 200 # view created key [root@ip-10-82-221-216 doc]# curl --write-out %{http_code} http://127.0.0.1:9090/myBucket <objects> <object> <bucket>myBucket</bucket> <key>drop1</key> </object> </objects> 200 # create attribute, notice 201 response [root@ip-10-82-221-216 doc]# curl --write-out %{http_code} --request PUT -d 'blue' http://127.0.0.1:9090/myBucket/drop1/color 201 # view created attribute [root@ip-10-82-221-216 doc]# curl --write-out %{http_codhttp://127.0.0.1:9090/myBucket/drop1/_attrs<object> <object_body path="http://127.0.0.1:9090/myBucket/drop1"/> <object_attr_list path="http://127.0.0.1:9090/myBucket/drop1/_attrs"/> <object_attr name="color" path="http://127.0.0.1:9090/myBucket/drop1/color"/> </object> 200