]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
allow cr http client to deal with non json types
authorAbhishek Lekshmanan <abhishek@suse.com>
Mon, 27 Mar 2017 13:03:11 +0000 (15:03 +0200)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 10 Apr 2018 15:03:10 +0000 (08:03 -0700)
I'm quite crossed about this!

Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
src/rgw/rgw_cr_rest.h

index f1897edb8576b4d50dd5b420961f2fcd8a6e6686..de31ad0a36ebc077a62e366dac6638b3fb90acb0 100644 (file)
@@ -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<RGWRESTReadResource> 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) {