From 6693737f46ffcf9f2f510b3c87e49dd3895c2173 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Tue, 8 Sep 2015 16:12:10 -0400 Subject: [PATCH] rgw: POST /admin/realm/period reads in json data Signed-off-by: Casey Bodley --- src/rgw/rgw_rest_config.cc | 22 +++++++++++----------- src/rgw/rgw_rest_config.h | 6 ++---- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/rgw/rgw_rest_config.cc b/src/rgw/rgw_rest_config.cc index aac2f5d70f6b9..975cb64d18700 100644 --- a/src/rgw/rgw_rest_config.cc +++ b/src/rgw/rgw_rest_config.cc @@ -73,23 +73,23 @@ void RGWOp_Period_Post::execute() { epoch_t epoch = 0; RESTArgs::get_uint32(s, "epoch", 0, &epoch); - period = new RGWPeriod(g_ceph_context, store); - http_ret = period->init(period_id, epoch); + RGWPeriod period(g_ceph_context, store); + http_ret = period.init(period_id, epoch); if (http_ret < 0) { dout(5) << "failed to read period" << dendl; + return; } -} -void RGWOp_Period_Post::send_response() { - set_req_state_err(s, http_ret); - dump_errno(s); - end_header(s); - - if (http_ret < 0) +#define PERIOD_INPUT_MAX_LEN 4096 + bool empty; + http_ret = rgw_rest_get_json_input(store->ctx(), s, period, + PERIOD_INPUT_MAX_LEN, &empty); + if (http_ret < 0) { + dout(5) << "failed to decode period" << dendl; return; + } - encode_json("period", *period, s->formatter); - flusher.flush(); + period.store_info(false); } RGWOp* RGWHandler_Config::op_get() { diff --git a/src/rgw/rgw_rest_config.h b/src/rgw/rgw_rest_config.h index 88e674aba6d77..19d0379d718f3 100644 --- a/src/rgw/rgw_rest_config.h +++ b/src/rgw/rgw_rest_config.h @@ -47,16 +47,14 @@ public: }; class RGWOp_Period_Post : public RGWRESTOp { - RGWPeriod *period; public: - RGWOp_Period_Post() : period(NULL) {} - ~RGWOp_Period_Post() { delete period; } + RGWOp_Period_Post() {} + ~RGWOp_Period_Post() {} int verify_permission() { return 0; } void execute(); - virtual void send_response(); virtual const string name() { return "post_period"; } -- 2.39.5