From 870872455789a3ab3f490ef50f6bc5bc09a3d8e5 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 29 Nov 2012 16:48:46 -0800 Subject: [PATCH] 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 --- src/common/config_opts.h | 1 + src/rgw/rgw_rest_s3.cc | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index b04a28f3259af..a9a2a159ca86e 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 f200db847fa97..b2925940f77fc 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); } -- 2.39.5