From: Abhishek Lekshmanan Date: Mon, 27 Mar 2017 13:03:11 +0000 (+0200) Subject: allow cr http client to deal with non json types X-Git-Tag: v13.1.0~270^2~121 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=57f2605010d52c2890cabda860a01668c6f9a0b3;p=ceph.git allow cr http client to deal with non json types I'm quite crossed about this! Signed-off-by: Abhishek Lekshmanan --- diff --git a/src/rgw/rgw_cr_rest.h b/src/rgw/rgw_cr_rest.h index f1897edb8576..de31ad0a36eb 100644 --- a/src/rgw/rgw_cr_rest.h +++ b/src/rgw/rgw_cr_rest.h @@ -14,7 +14,8 @@ class RGWReadRESTResourceCR : public RGWSimpleCoroutine { string path; param_vec_t params; T *result; - + bool raw; // raw result, T should be a bufferlist + bufferlist* result_bl; boost::intrusive_ptr http_op; public: @@ -22,7 +23,14 @@ public: RGWHTTPManager *_http_manager, const string& _path, rgw_http_param_pair *params, T *_result) : RGWSimpleCoroutine(_cct), conn(_conn), http_manager(_http_manager), - path(_path), params(make_param_list(params)), result(_result) + path(_path), params(make_param_list(params)), result(_result), raw(false) + {} + + RGWReadRESTResourceCR(CephContext *_cct, RGWRESTConn *_conn, + RGWHTTPManager *_http_manager, const string& _path, + rgw_http_param_pair *params, T *_result, bool _raw, bufferlist* _result_bl) + : RGWSimpleCoroutine(_cct), conn(_conn), http_manager(_http_manager), + path(_path), params(make_param_list(params)), result(_result), raw(_raw), result_bl(_result_bl) {} ~RGWReadRESTResourceCR() override { @@ -46,18 +54,27 @@ public: return 0; } + int request_complete() override { - int ret = http_op->wait(result); + int ret; + if (!raw) + ret = http_op->wait(result); + else{ + // forgive me + ret = http_op->wait_bl(result_bl); + //bl->encode(result); + } + + auto op = std::move(http_op); // release ref on return if (ret < 0) { error_stream << "http operation failed: " << op->to_str() - << " status=" << op->get_http_status() << std::endl; + << " status=" << op->get_http_status() << std::endl; op->put(); return ret; } op->put(); return 0; - } void request_cleanup() override { if (http_op) {