From 4577a722b69dd317044fd05ddb1ebf642e467016 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Wed, 30 Jan 2019 15:15:56 -0800 Subject: [PATCH] rgw: es: use default request headers for query requests Needed for sending auth headers. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_sync_module_es.cc | 12 ++++++++++++ src/rgw/rgw_sync_module_es.h | 1 + src/rgw/rgw_sync_module_es_rest.cc | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_sync_module_es.cc b/src/rgw/rgw_sync_module_es.cc index 8723c5f6f98..f9b02a4027b 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 1b5506c3579..cb5c9106225 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 8a8d895b326..751d822085f 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; -- 2.39.5