summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2012-11-29 16:48:46 -0800
committerYehuda Sadeh <yehuda@inktank.com>2012-12-12 13:45:21 -0800
commit870872455789a3ab3f490ef50f6bc5bc09a3d8e5 (patch)
tree52a1ef158a1e4e43b8b6f08cfdd5ce727cfee56b
parentbece012caaf5cd89cc727d93e38eeb34b6649db1 (diff)
downloadceph-870872455789a3ab3f490ef50f6bc5bc09a3d8e5.tar.gz
rgw: option to provide alternative s3 put obj success code
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>
-rw-r--r--src/common/config_opts.h1
-rw-r--r--src/rgw/rgw_rest_s3.cc15
2 files changed, 16 insertions, 0 deletions
diff --git a/src/common/config_opts.h b/src/common/config_opts.h
index b04a28f3259..a9a2a159ca8 100644
--- a/src/common/config_opts.h
+++ b/src/common/config_opts.h
@@ -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)
diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc
index f200db847fa..b2925940f77 100644
--- a/src/rgw/rgw_rest_s3.cc
+++ b/src/rgw/rgw_rest_s3.cc
@@ -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);
}