]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_cr_rest: support extra headers for get resource crs
authorAbhishek Lekshmanan <abhishek@suse.com>
Wed, 16 May 2018 11:17:28 +0000 (13:17 +0200)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 25 Jan 2019 23:45:57 +0000 (15:45 -0800)
Adding support to add additional headers as a part of GET and READ requests.

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

index 821e76d253c76037434144ef5ac947d4e9371a0c..c67b0006b9529d7b03f59624dc88809de5dc6486 100644 (file)
@@ -31,7 +31,8 @@ class RGWReadRawRESTResourceCR : public RGWSimpleCoroutine {
   RGWHTTPManager *http_manager;
   string path;
   param_vec_t params;
- public:
+  param_vec_t extra_headers;
+public:
   boost::intrusive_ptr<RGWRESTReadResource> http_op;
   RGWReadRawRESTResourceCR(CephContext *_cct, RGWRESTConn *_conn,
                            RGWHTTPManager *_http_manager, const string& _path,
@@ -47,6 +48,23 @@ class RGWReadRawRESTResourceCR : public RGWSimpleCoroutine {
     path(_path), params(make_param_list(params))
   {}
 
+  RGWReadRawRESTResourceCR(CephContext *_cct, RGWRESTConn *_conn,
+                           RGWHTTPManager *_http_manager, const string& _path,
+                           rgw_http_param_pair *params, param_vec_t &hdrs)
+    : RGWSimpleCoroutine(_cct), conn(_conn), http_manager(_http_manager),
+      path(_path), params(make_param_list(params)),
+      extra_headers(hdrs)
+  {}
+
+ RGWReadRawRESTResourceCR(CephContext *_cct, RGWRESTConn *_conn,
+                          RGWHTTPManager *_http_manager, const string& _path,
+                          rgw_http_param_pair *params,
+                          std::map <std::string, std::string> *hdrs)
+   : RGWSimpleCoroutine(_cct), conn(_conn), http_manager(_http_manager),
+    path(_path), params(make_param_list(params)),
+    extra_headers(make_param_list(hdrs))
+    {}
+
 
   ~RGWReadRawRESTResourceCR() override {
     request_cleanup();
@@ -54,7 +72,7 @@ class RGWReadRawRESTResourceCR : public RGWSimpleCoroutine {
 
   int send_request() override {
     auto op = boost::intrusive_ptr<RGWRESTReadResource>(
-        new RGWRESTReadResource(conn, path, params, NULL, http_manager));
+        new RGWRESTReadResource(conn, path, params, &extra_headers, http_manager));
 
     init_new_io(op.get());
 
@@ -111,6 +129,14 @@ class RGWReadRESTResourceCR : public RGWReadRawRESTResourceCR {
    : RGWReadRawRESTResourceCR(_cct, _conn, _http_manager, _path, params), result(_result)
   {}
 
+  RGWReadRESTResourceCR(CephContext *_cct, RGWRESTConn *_conn,
+                        RGWHTTPManager *_http_manager, const string& _path,
+                        rgw_http_param_pair *params,
+                        std::map <std::string, std::string> *hdrs,
+                        T *_result)
+    : RGWReadRawRESTResourceCR(_cct, _conn, _http_manager, _path, params, hdrs), result(_result)
+  {}
+
   int wait_result() override {
     return http_op->wait(result);
   }
index d98190e4bfe7119b7168a9e9f70579170e924419..5b6b11c864e81f459be7626c9ec9145419a6de3e 100644 (file)
@@ -565,10 +565,15 @@ public:
   int operate() override {
     reenter(this) {
       ldout(sync_env->cct, 0) << ": init elasticsearch config zone=" << sync_env->source_zone << dendl;
-      yield call(new RGWReadRESTResourceCR<ESInfo> (sync_env->cct,
-                                                    conf->conn.get(),
-                                                    sync_env->http_manager,
-                                                    "/", nullptr, &es_info));
+      yield {
+        auto hdrs = make_param_list(&conf->default_headers);
+        call(new RGWReadRESTResourceCR<ESInfo> (sync_env->cct,
+                                                conf->conn.get(),
+                                                sync_env->http_manager,
+                                                "/", nullptr /*params*/,
+                                                &hdrs,
+                                                &es_info));
+      }
       if (retcode < 0) {
         return set_cr_error(retcode);
       }