]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: option to provide alternative s3 put obj success code
authorYehuda Sadeh <yehuda@inktank.com>
Fri, 30 Nov 2012 00:48:46 +0000 (16:48 -0800)
committerYehuda Sadeh <yehuda@inktank.com>
Wed, 12 Dec 2012 21:45:21 +0000 (13:45 -0800)
Fixes: #3529
Added a new option: rgw_s3_success_create_obj_status.
Expected values are 0, 200, 201, 204. A value of 0
will skip the special handling altogether. Any value
other than the specified will default to 200.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/common/config_opts.h
src/rgw/rgw_rest_s3.cc

index b04a28f3259afae6b583ba0f855de058d1a8da5b..a9a2a159ca86ebae8f78a6df13384c8363699e8a 100644 (file)
@@ -483,6 +483,7 @@ OPTION(rgw_gc_max_objs, OPT_INT, 32)
 OPTION(rgw_gc_obj_min_wait, OPT_INT, 2 * 3600)    // wait time before object may be handled by gc
 OPTION(rgw_gc_processor_max_time, OPT_INT, 3600)  // total run time for a single gc processor work
 OPTION(rgw_gc_processor_period, OPT_INT, 3600)  // gc processor cycle time
+OPTION(rgw_s3_success_create_obj_status, OPT_INT, 0) // alternative success status response for create-obj (0 - default)
 OPTION(rgw_resolve_cname, OPT_BOOL, false)  // should rgw try to resolve hostname as a dns cname record
 OPTION(rgw_obj_stripe_size, OPT_INT, 4 << 20)
 
index f200db847fa9783f6b645a457c27ddc24bc23ba7..b2925940f77fc32e90ca04abfcae255ba1683988 100644 (file)
@@ -352,11 +352,26 @@ int RGWPutObj_ObjStore_S3::get_params()
   return RGWPutObj_ObjStore::get_params();
 }
 
+static int get_success_retcode(int code)
+{
+  switch (code) {
+    case 201:
+      return STATUS_CREATED;
+    case 204:
+      return STATUS_NO_CONTENT;
+  }
+  return 0;
+}
+
 void RGWPutObj_ObjStore_S3::send_response()
 {
   if (ret) {
     set_req_state_err(s, ret);
   } else {
+    if (s->cct->_conf->rgw_s3_success_create_obj_status) {
+      ret = get_success_retcode(s->cct->_conf->rgw_s3_success_create_obj_status);
+      set_req_state_err(s, ret);
+    }
     dump_etag(s, etag.c_str());
     dump_content_length(s, 0);
   }