From: Abhishek Lekshmanan Date: Wed, 16 May 2018 11:17:28 +0000 (+0200) Subject: rgw_cr_rest: support extra headers for get resource crs X-Git-Tag: v14.1.0~210^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=21bb91e80947f46d638ad8f3698a6dbda51b6bc8;p=ceph.git rgw_cr_rest: support extra headers for get resource crs Adding support to add additional headers as a part of GET and READ requests. Signed-off-by: Abhishek Lekshmanan --- diff --git a/src/rgw/rgw_cr_rest.h b/src/rgw/rgw_cr_rest.h index 821e76d253c7..c67b0006b952 100644 --- a/src/rgw/rgw_cr_rest.h +++ b/src/rgw/rgw_cr_rest.h @@ -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 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 *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( - 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 *hdrs, + T *_result) + : RGWReadRawRESTResourceCR(_cct, _conn, _http_manager, _path, params, hdrs), result(_result) + {} + int wait_result() override { return http_op->wait(result); } diff --git a/src/rgw/rgw_sync_module_es.cc b/src/rgw/rgw_sync_module_es.cc index d98190e4bfe7..5b6b11c864e8 100644 --- a/src/rgw/rgw_sync_module_es.cc +++ b/src/rgw/rgw_sync_module_es.cc @@ -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 (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 (sync_env->cct, + conf->conn.get(), + sync_env->http_manager, + "/", nullptr /*params*/, + &hdrs, + &es_info)); + } if (retcode < 0) { return set_cr_error(retcode); }