From: Yehuda Sadeh Date: Wed, 30 Jan 2019 23:15:56 +0000 (-0800) Subject: rgw: es: use default request headers for query requests X-Git-Tag: v14.1.0~210^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F26106%2Fhead;p=ceph.git rgw: es: use default request headers for query requests Needed for sending auth headers. Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_sync_module_es.cc b/src/rgw/rgw_sync_module_es.cc index 8723c5f6f985..f9b02a4027bb 100644 --- a/src/rgw/rgw_sync_module_es.cc +++ b/src/rgw/rgw_sync_module_es.cc @@ -211,6 +211,10 @@ struct ElasticConfig { return index_path; } + map& get_request_headers() { + return default_headers; + } + string get_obj_path(const RGWBucketInfo& bucket_info, const rgw_obj_key& key) { return index_path + "/object/" + url_encode(bucket_info.bucket.bucket_id + ":" + key.name + ":" + (key.instance.empty() ? "null" : key.instance)); } @@ -834,6 +838,10 @@ public: string get_index_path() { return conf->get_index_path(); } + + map& get_request_headers() { + return conf->get_request_headers(); + } }; RGWElasticSyncModuleInstance::RGWElasticSyncModuleInstance(CephContext *cct, const JSONFormattable& config) @@ -855,6 +863,10 @@ string RGWElasticSyncModuleInstance::get_index_path() { return data_handler->get_index_path(); } +map& RGWElasticSyncModuleInstance::get_request_headers() { + return data_handler->get_request_headers(); +} + RGWRESTMgr *RGWElasticSyncModuleInstance::get_rest_filter(int dialect, RGWRESTMgr *orig) { if (dialect != RGW_REST_S3) { return orig; diff --git a/src/rgw/rgw_sync_module_es.h b/src/rgw/rgw_sync_module_es.h index 1b5506c35799..cb5c91062250 100644 --- a/src/rgw/rgw_sync_module_es.h +++ b/src/rgw/rgw_sync_module_es.h @@ -53,6 +53,7 @@ public: RGWRESTMgr *get_rest_filter(int dialect, RGWRESTMgr *orig) override; RGWRESTConn *get_rest_conn(); std::string get_index_path(); + map& get_request_headers(); bool supports_user_writes() override { return true; } diff --git a/src/rgw/rgw_sync_module_es_rest.cc b/src/rgw/rgw_sync_module_es_rest.cc index 8a8d895b3265..751d822085f2 100644 --- a/src/rgw/rgw_sync_module_es_rest.cc +++ b/src/rgw/rgw_sync_module_es_rest.cc @@ -245,7 +245,7 @@ void RGWMetadataSearchOp::execute() params.push_back(param_pair_t("from", marker_str.c_str())); } ldout(s->cct, 20) << "sending request to elasticsearch, payload=" << string(in.c_str(), in.length()) << dendl; - map extra_headers = {{"Content-Type", "application/json"}}; + auto& extra_headers = es_module->get_request_headers(); op_ret = conn->get_resource(resource, ¶ms, &extra_headers, out, &in); if (op_ret < 0) { ldout(s->cct, 0) << "ERROR: failed to fetch resource (r=" << resource << ", ret=" << op_ret << ")" << dendl;