From b0c6e9a71e684cae6508fddb5e2e80a17fd8543d Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 24 Aug 2017 06:16:54 -0700 Subject: [PATCH] rgw: tweak http client interface RGWHTTPClient now holds the url and method. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_admin.cc | 2 +- src/rgw/rgw_auth_keystone.cc | 10 ++++---- src/rgw/rgw_crypt.cc | 4 ++-- src/rgw/rgw_http_client.cc | 33 ++++++++++----------------- src/rgw/rgw_http_client.h | 44 ++++++++++++++++++++++++------------ src/rgw/rgw_keystone.cc | 18 ++++++++++----- src/rgw/rgw_keystone.h | 4 +++- src/rgw/rgw_rest_client.cc | 41 +++++++++++++++++++++------------ src/rgw/rgw_rest_client.h | 42 +++++++++++++++++++--------------- src/rgw/rgw_rest_conn.cc | 4 ++-- src/rgw/rgw_swift_auth.cc | 4 ++-- 11 files changed, 120 insertions(+), 86 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index f8c0eda7349c0..108ef37982338 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -1671,7 +1671,7 @@ static int send_to_url(const string& url, const string& access, key.key = secret; param_vec_t params; - RGWRESTSimpleRequest req(g_ceph_context, url, NULL, ¶ms); + RGWRESTSimpleRequest req(g_ceph_context, info.method, url, NULL, ¶ms); bufferlist response; int ret = req.forward_request(key, info, MAX_REST_RESPONSE, &in_data, &response); diff --git a/src/rgw/rgw_auth_keystone.cc b/src/rgw/rgw_auth_keystone.cc index 1421f89983cc2..21a71c5a73377 100644 --- a/src/rgw/rgw_auth_keystone.cc +++ b/src/rgw/rgw_auth_keystone.cc @@ -69,7 +69,7 @@ TokenEngine::get_from_keystone(const std::string& token) const /* The container for plain response obtained from Keystone. It will be * parsed token_envelope_t::parse method. */ ceph::bufferlist token_body_bl; - RGWValidateKeystoneToken validate(cct, &token_body_bl); + RGWValidateKeystoneToken validate(cct, "GET", "", &token_body_bl); std::string url = config.get_endpoint_url(); if (url.empty()) { @@ -93,7 +93,9 @@ TokenEngine::get_from_keystone(const std::string& token) const validate.append_header("X-Auth-Token", admin_token); validate.set_send_length(0); - int ret = validate.process(url.c_str()); + validate.set_url(url); + + int ret = validate.process(); if (ret < 0) { throw ret; } @@ -324,7 +326,7 @@ EC2Engine::get_from_keystone(const boost::string_view& access_key_id, /* The container for plain response obtained from Keystone. It will be * parsed token_envelope_t::parse method. */ ceph::bufferlist token_body_bl; - RGWValidateKeystoneToken validate(cct, &token_body_bl); + RGWValidateKeystoneToken validate(cct, "POST", keystone_url, &token_body_bl); /* set required headers for keystone request */ validate.append_header("X-Auth-Token", admin_token); @@ -349,7 +351,7 @@ EC2Engine::get_from_keystone(const boost::string_view& access_key_id, validate.set_send_length(os.str().length()); /* send request */ - ret = validate.process("POST", keystone_url.c_str()); + ret = validate.process(); if (ret < 0) { ldout(cct, 2) << "s3 keystone: token validation ERROR: " << token_body_bl.c_str() << dendl; diff --git a/src/rgw/rgw_crypt.cc b/src/rgw/rgw_crypt.cc index 1b2de8ce72f35..f8d6f1095e415 100644 --- a/src/rgw/rgw_crypt.cc +++ b/src/rgw/rgw_crypt.cc @@ -761,11 +761,11 @@ static int request_key_from_barbican(CephContext *cct, secret_url += "v1/secrets/" + std::string(key_id); bufferlist secret_bl; - RGWHTTPTransceiver secret_req(cct, &secret_bl); + RGWHTTPTransceiver secret_req(cct, "GET", secret_url, &secret_bl); secret_req.append_header("Accept", "application/octet-stream"); secret_req.append_header("X-Auth-Token", barbican_token); - res = secret_req.process("GET", secret_url.c_str()); + res = secret_req.process(); if (res < 0) { return res; } diff --git a/src/rgw/rgw_http_client.cc b/src/rgw/rgw_http_client.cc index 68a426c41a632..d0f90a5617d21 100644 --- a/src/rgw/rgw_http_client.cc +++ b/src/rgw/rgw_http_client.cc @@ -414,28 +414,22 @@ static curl_slist *headers_to_slist(param_vec_t& headers) return h; } -static bool is_upload_request(const char *method) +static bool is_upload_request(const string& method) { - if (method == nullptr) { - return false; - } - return strcmp(method, "POST") == 0 || strcmp(method, "PUT") == 0; + return method == "POST" || method == "PUT"; } /* * process a single simple one off request, not going through RGWHTTPManager. Not using * req_data. */ -int RGWHTTPClient::process(const char *method, const char *url) +int RGWHTTPClient::process() { int ret = 0; CURL *curl_handle; char error_buf[CURL_ERROR_SIZE]; - last_method = (method ? method : ""); - last_url = (url ? url : ""); - auto ca = handles->get_curl_handle(); curl_handle = **ca; @@ -443,8 +437,8 @@ int RGWHTTPClient::process(const char *method, const char *url) curl_slist *h = headers_to_slist(headers); - curl_easy_setopt(curl_handle, CURLOPT_CUSTOMREQUEST, method); - curl_easy_setopt(curl_handle, CURLOPT_URL, url); + curl_easy_setopt(curl_handle, CURLOPT_CUSTOMREQUEST, method.c_str()); + curl_easy_setopt(curl_handle, CURLOPT_URL, url.c_str()); curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L); curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1L); curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, simple_receive_http_header); @@ -483,8 +477,8 @@ int RGWHTTPClient::process(const char *method, const char *url) string RGWHTTPClient::to_str() { - string method_str = (last_method.empty() ? "" : last_method); - string url_str = (last_url.empty() ? "" : last_url); + string method_str = (method.empty() ? "" : method); + string url_str = (url.empty() ? "" : url); return method_str + " " + url_str; } @@ -500,7 +494,7 @@ int RGWHTTPClient::get_req_retcode() /* * init request, will be used later with RGWHTTPManager */ -int RGWHTTPClient::init_request(const char *method, const char *url, rgw_http_req_data *_req_data, bool send_data_hint) +int RGWHTTPClient::init_request(rgw_http_req_data *_req_data, bool send_data_hint) { assert(!req_data); _req_data->get(); @@ -518,11 +512,8 @@ int RGWHTTPClient::init_request(const char *method, const char *url, rgw_http_re req_data->h = h; - last_method = (method ? method : ""); - last_url = (url ? url : ""); - - curl_easy_setopt(easy_handle, CURLOPT_CUSTOMREQUEST, method); - curl_easy_setopt(easy_handle, CURLOPT_URL, url); + curl_easy_setopt(easy_handle, CURLOPT_CUSTOMREQUEST, method.c_str()); + curl_easy_setopt(easy_handle, CURLOPT_URL, url.c_str()); curl_easy_setopt(easy_handle, CURLOPT_NOPROGRESS, 1L); curl_easy_setopt(easy_handle, CURLOPT_NOSIGNAL, 1L); curl_easy_setopt(easy_handle, CURLOPT_HEADERFUNCTION, receive_http_header); @@ -950,11 +941,11 @@ void RGWHTTPManager::manage_pending_requests() } } -int RGWHTTPManager::add_request(RGWHTTPClient *client, const char *method, const char *url, bool send_data_hint) +int RGWHTTPManager::add_request(RGWHTTPClient *client, bool send_data_hint) { rgw_http_req_data *req_data = new rgw_http_req_data; - int ret = client->init_request(method, url, req_data, send_data_hint); + int ret = client->init_request(req_data, send_data_hint); if (ret < 0) { req_data->put(); req_data = NULL; diff --git a/src/rgw/rgw_http_client.h b/src/rgw/rgw_http_client.h index 40c4bf15a084e..a8bbaa17b9651 100644 --- a/src/rgw/rgw_http_client.h +++ b/src/rgw/rgw_http_client.h @@ -31,21 +31,21 @@ class RGWHTTPClient void *user_info; - string last_method; - string last_url; bool verify_ssl; // Do not validate self signed certificates, default to false std::atomic stopped { 0 }; protected: CephContext *cct; + + string method; + string url; + param_vec_t headers; RGWHTTPManager *get_manager(); - int init_request(const char *method, - const char *url, - rgw_http_req_data *req_data, + int init_request(rgw_http_req_data *req_data, bool send_data_hint = false); virtual int receive_header(void *ptr, size_t len) { @@ -99,14 +99,18 @@ public: static const long HTTP_STATUS_NOTFOUND = 404; virtual ~RGWHTTPClient(); - explicit RGWHTTPClient(CephContext *cct) + explicit RGWHTTPClient(CephContext *cct, + const string& _method, + const string& _url) : send_len(0), has_send_len(false), http_status(HTTP_STATUS_NOSTATUS), req_data(nullptr), user_info(nullptr), verify_ssl(cct->_conf->rgw_verify_ssl), - cct(cct) { + cct(cct), + method(_method), + url(_url) { } void set_user_info(void *info) { @@ -135,8 +139,7 @@ public: verify_ssl = flag; } - int process(const char *method, const char *url); - int process(const char *url) { return process("GET", url); } + int process(); int wait(); rgw_http_req_data *get_req_data() { return req_data; } @@ -144,6 +147,14 @@ public: string to_str(); int get_req_retcode(); + + void set_url(const string& _url) { + url = _url; + } + + void set_method(const string& _method) { + method = _method; + } }; @@ -154,8 +165,10 @@ public: typedef std::set header_spec_t; RGWHTTPHeadersCollector(CephContext * const cct, + const string& method, + const string& url, const header_spec_t &relevant_headers) - : RGWHTTPClient(cct), + : RGWHTTPClient(cct, method, url), relevant_headers(relevant_headers) { } @@ -192,18 +205,22 @@ class RGWHTTPTransceiver : public RGWHTTPHeadersCollector { public: RGWHTTPTransceiver(CephContext * const cct, + const string& method, + const string& url, bufferlist * const read_bl, const header_spec_t intercept_headers = {}) - : RGWHTTPHeadersCollector(cct, intercept_headers), + : RGWHTTPHeadersCollector(cct, method, url, intercept_headers), read_bl(read_bl), post_data_index(0) { } RGWHTTPTransceiver(CephContext * const cct, + const string& method, + const string& url, bufferlist * const read_bl, const bool verify_ssl, const header_spec_t intercept_headers = {}) - : RGWHTTPHeadersCollector(cct, intercept_headers), + : RGWHTTPHeadersCollector(cct, method, url, intercept_headers), read_bl(read_bl), post_data_index(0) { set_verify_ssl(verify_ssl); @@ -290,8 +307,7 @@ public: int set_threaded(); void stop(); - int add_request(RGWHTTPClient *client, const char *method, const char *url, - bool send_data_hint = false); + int add_request(RGWHTTPClient *client, bool send_data_hint = false); int remove_request(RGWHTTPClient *client); int set_request_state(RGWHTTPClient *client, RGWHTTPRequestSetState state); diff --git a/src/rgw/rgw_keystone.cc b/src/rgw/rgw_keystone.cc index 2878cf70453ac..19386239b918d 100644 --- a/src/rgw/rgw_keystone.cc +++ b/src/rgw/rgw_keystone.cc @@ -212,7 +212,7 @@ int Service::issue_admin_token_request(CephContext* const cct, } bufferlist token_bl; - RGWGetKeystoneAdminToken token_req(cct, &token_bl); + RGWGetKeystoneAdminToken token_req(cct, "POST", "", &token_bl); token_req.append_header("Content-Type", "application/json"); JSONFormatter jf; @@ -240,7 +240,9 @@ int Service::issue_admin_token_request(CephContext* const cct, return -ENOTSUP; } - const int ret = token_req.process("POST", token_url.c_str()); + token_req.set_url(token_url); + + const int ret = token_req.process(); if (ret < 0) { return ret; } @@ -283,7 +285,7 @@ int Service::get_keystone_barbican_token(CephContext * const cct, } bufferlist token_bl; - RGWKeystoneHTTPTransceiver token_req(cct, &token_bl); + RGWKeystoneHTTPTransceiver token_req(cct, "POST", "", &token_bl); token_req.append_header("Content-Type", "application/json"); JSONFormatter jf; @@ -311,8 +313,10 @@ int Service::get_keystone_barbican_token(CephContext * const cct, return -ENOTSUP; } + token_req.set_url(token_url); + ldout(cct, 20) << "Requesting secret from barbican url=" << token_url << dendl; - const int ret = token_req.process("POST", token_url.c_str()); + const int ret = token_req.process(); if (ret < 0) { ldout(cct, 20) << "Barbican process error:" << token_bl.c_str() << dendl; return ret; @@ -516,7 +520,7 @@ int TokenCache::RevokeThread::check_revoked() std::string token; bufferlist bl; - RGWGetRevokedTokens req(cct, &bl); + RGWGetRevokedTokens req(cct, "GET", "", &bl); if (rgw::keystone::Service::get_admin_token(cct, *cache, config, token) < 0) { return -EINVAL; @@ -536,8 +540,10 @@ int TokenCache::RevokeThread::check_revoked() url.append("v3/auth/tokens/OS-PKI/revoked"); } + req.set_url(url); + req.set_send_length(0); - int ret = req.process(url.c_str()); + int ret = req.process(); if (ret < 0) { return ret; } diff --git a/src/rgw/rgw_keystone.h b/src/rgw/rgw_keystone.h index 1cdbae519c94f..05504527f2733 100644 --- a/src/rgw/rgw_keystone.h +++ b/src/rgw/rgw_keystone.h @@ -109,8 +109,10 @@ public: class RGWKeystoneHTTPTransceiver : public RGWHTTPTransceiver { public: RGWKeystoneHTTPTransceiver(CephContext * const cct, + const string& method, + const string& url, bufferlist * const token_body_bl) - : RGWHTTPTransceiver(cct, token_body_bl, + : RGWHTTPTransceiver(cct, method, url, token_body_bl, cct->_conf->rgw_keystone_verify_ssl, { "X-Subject-Token" }) { } diff --git a/src/rgw/rgw_rest_client.cc b/src/rgw/rgw_rest_client.cc index d317f891a6baf..93bfcedc57cf6 100644 --- a/src/rgw/rgw_rest_client.cc +++ b/src/rgw/rgw_rest_client.cc @@ -102,8 +102,9 @@ static void get_new_date_str(string& date_str) date_str = rgw_to_asctime(ceph_clock_now()); } -int RGWRESTSimpleRequest::execute(RGWAccessKey& key, const char *method, const char *resource) +int RGWRESTSimpleRequest::execute(RGWAccessKey& key, const char *_method, const char *resource) { + method = _method; string new_url = url; string new_resource = resource; @@ -114,6 +115,7 @@ int RGWRESTSimpleRequest::execute(RGWAccessKey& key, const char *method, const c new_resource.append(resource); } new_url.append(new_resource); + url = new_url; string date_str; get_new_date_str(date_str); @@ -122,8 +124,8 @@ int RGWRESTSimpleRequest::execute(RGWAccessKey& key, const char *method, const c string canonical_header; map meta_map; map sub_resources; - rgw_create_s3_canonical_header(method, NULL, NULL, date_str.c_str(), - meta_map, new_url.c_str(), sub_resources, + rgw_create_s3_canonical_header(method.c_str(), NULL, NULL, date_str.c_str(), + meta_map, url.c_str(), sub_resources, canonical_header); string digest; @@ -138,7 +140,7 @@ int RGWRESTSimpleRequest::execute(RGWAccessKey& key, const char *method, const c ldout(cct, 15) << "generated auth header: " << auth_hdr << dendl; headers.push_back(pair("AUTHORIZATION", auth_hdr)); - int r = process(method, new_url.c_str()); + int r = process(); if (r < 0) return r; @@ -292,7 +294,10 @@ int RGWRESTSimpleRequest::forward_request(RGWAccessKey& key, req_info& info, siz set_send_length(inbl->length()); } - int r = process(new_info.method, new_url.c_str()); + method = new_info.method; + url = new_url; + + int r = process(); if (r < 0){ if (r == -EINVAL){ // curl_easy has errored, generally means the service is not available @@ -492,7 +497,10 @@ int RGWRESTStreamWriteRequest::put_obj_init(RGWAccessKey& key, rgw_obj& obj, uin set_send_length(obj_size); - int r = http_manager.add_request(this, new_info.method, new_url.c_str()); + method = new_info.method; + url = new_url; + + int r = http_manager.add_request(this); if (r < 0) return r; @@ -654,7 +662,7 @@ int RGWRESTStreamRWRequest::send_request(RGWAccessKey *key, map& new_env.set(iter->first.c_str(), iter->second.c_str()); } - new_info.method = method; + new_info.method = method.c_str(); new_info.script_uri = "/"; new_info.script_uri.append(new_resource); @@ -676,7 +684,7 @@ int RGWRESTStreamRWRequest::send_request(RGWAccessKey *key, map& bool send_data_hint = false; if (send_data) { - outbl.claim(*send_data); + set_outbl(*send_data); send_data_hint = true; } @@ -694,7 +702,10 @@ int RGWRESTStreamRWRequest::send_request(RGWAccessKey *key, map& set_send_length(send_size); } - int r = pmanager->add_request(this, new_info.method, new_url.c_str(), send_data_hint); + method = new_info.method; + url = new_url; + + int r = pmanager->add_request(this, send_data_hint); if (r < 0) return r; @@ -759,7 +770,7 @@ int RGWRESTStreamRWRequest::complete_request(string& etag, real_time *mtime, uin return status; } -int RGWRESTStreamRWRequest::handle_header(const string& name, const string& val) +int RGWHTTPStreamRWRequest::handle_header(const string& name, const string& val) { if (name == "RGWX_EMBEDDED_METADATA_LEN") { string err; @@ -774,7 +785,7 @@ int RGWRESTStreamRWRequest::handle_header(const string& name, const string& val) return 0; } -int RGWRESTStreamRWRequest::receive_data(void *ptr, size_t len) +int RGWHTTPStreamRWRequest::receive_data(void *ptr, size_t len) { bufferptr bp((const char *)ptr, len); bufferlist bl; @@ -786,12 +797,12 @@ int RGWRESTStreamRWRequest::receive_data(void *ptr, size_t len) return len; } -void RGWRESTStreamRWRequest::set_stream_write(bool s) { +void RGWHTTPStreamRWRequest::set_stream_write(bool s) { Mutex::Locker wl(write_lock); stream_writes = s; } -void RGWRESTStreamRWRequest::add_send_data(bufferlist& bl) +void RGWHTTPStreamRWRequest::add_send_data(bufferlist& bl) { Mutex::Locker req_locker(get_req_lock()); Mutex::Locker wl(write_lock); @@ -799,7 +810,7 @@ void RGWRESTStreamRWRequest::add_send_data(bufferlist& bl) _set_write_paused(false); } -void RGWRESTStreamRWRequest::finish_write() +void RGWHTTPStreamRWRequest::finish_write() { Mutex::Locker req_locker(get_req_lock()); Mutex::Locker wl(write_lock); @@ -807,7 +818,7 @@ void RGWRESTStreamRWRequest::finish_write() _set_write_paused(false); } -int RGWRESTStreamRWRequest::send_data(void *ptr, size_t len, bool *pause) +int RGWHTTPStreamRWRequest::send_data(void *ptr, size_t len, bool *pause) { Mutex::Locker wl(write_lock); diff --git a/src/rgw/rgw_rest_client.h b/src/rgw/rgw_rest_client.h index 09f98532432c9..c71b50750dfe1 100644 --- a/src/rgw/rgw_rest_client.h +++ b/src/rgw/rgw_rest_client.h @@ -13,8 +13,6 @@ protected: int http_status; int status; - string url; - map out_headers; param_vec_t params; @@ -29,9 +27,10 @@ protected: int sign_request(RGWAccessKey& key, RGWEnv& env, req_info& info); public: - RGWRESTSimpleRequest(CephContext *_cct, const string& _url, param_vec_t *_headers, - param_vec_t *_params) : RGWHTTPClient(_cct), http_status(0), status(0), - url(_url), send_iter(NULL), + RGWRESTSimpleRequest(CephContext *_cct, const string& _method, const string& _url, + param_vec_t *_headers, param_vec_t *_params) : RGWHTTPClient(_cct, _method, _url), + http_status(0), status(0), + send_iter(NULL), max_response(0) { set_headers(_headers); set_params(_params); @@ -72,8 +71,8 @@ public: int add_output_data(bufferlist& bl); int send_data(void *ptr, size_t len) override; - RGWRESTStreamWriteRequest(CephContext *_cct, const string& _url, param_vec_t *_headers, - param_vec_t *_params) : RGWRESTSimpleRequest(_cct, _url, _headers, _params), + RGWRESTStreamWriteRequest(CephContext *_cct, const string& _method, const string& _url, param_vec_t *_headers, + param_vec_t *_params) : RGWRESTSimpleRequest(_cct, _method, _url, _headers, _params), lock("RGWRESTStreamWriteRequest"), cb(NULL), http_manager(_cct) {} ~RGWRESTStreamWriteRequest() override; int put_obj_init(RGWAccessKey& key, rgw_obj& obj, uint64_t obj_size, map& attrs); @@ -82,7 +81,7 @@ public: RGWGetDataCB *get_out_cb() { return cb; } }; -class RGWRESTStreamRWRequest : public RGWRESTSimpleRequest { +class RGWHTTPStreamRWRequest : public RGWRESTSimpleRequest { Mutex lock; Mutex write_lock; RGWGetDataCB *cb; @@ -90,8 +89,6 @@ class RGWRESTStreamRWRequest : public RGWRESTSimpleRequest { bufferlist in_data; size_t chunk_ofs{0}; size_t ofs{0}; - RGWHTTPManager http_manager; - const char *method; uint64_t write_ofs{0}; bool send_paused{false}; bool stream_writes{false}; @@ -102,15 +99,11 @@ public: int send_data(void *ptr, size_t len, bool *pause) override; int receive_data(void *ptr, size_t len) override; - RGWRESTStreamRWRequest(CephContext *_cct, const char *_method, const string& _url, RGWGetDataCB *_cb, - param_vec_t *_headers, param_vec_t *_params) : RGWRESTSimpleRequest(_cct, _url, _headers, _params), - lock("RGWRESTStreamRWRequest"), write_lock("RGWRESTStreamRWRequest::write_lock"), cb(_cb), - http_manager(_cct), method(_method) { + RGWHTTPStreamRWRequest(CephContext *_cct, const string& _method, const string& _url, RGWGetDataCB *_cb, + param_vec_t *_headers, param_vec_t *_params) : RGWRESTSimpleRequest(_cct, _method, _url, _headers, _params), + lock("RGWRESTStreamRWRequest"), write_lock("RGWRESTStreamRWRequest::write_lock"), cb(_cb) { } - virtual ~RGWRESTStreamRWRequest() override {} - int send_request(RGWAccessKey& key, map& extra_headers, rgw_obj& obj, RGWHTTPManager *mgr = NULL); - int send_request(RGWAccessKey *key, map& extra_headers, const string& resource, bufferlist *send_data = NULL /* optional input data */, RGWHTTPManager *mgr = NULL); - int complete_request(string& etag, real_time *mtime, uint64_t *psize, map& attrs); + virtual ~RGWHTTPStreamRWRequest() override {} void set_outbl(bufferlist& _outbl) { outbl.swap(_outbl); @@ -126,6 +119,19 @@ public: void finish_write(); }; +class RGWRESTStreamRWRequest : public RGWHTTPStreamRWRequest { + RGWHTTPManager http_manager; +public: + RGWRESTStreamRWRequest(CephContext *_cct, const string& _method, const string& _url, RGWGetDataCB *_cb, + param_vec_t *_headers, param_vec_t *_params) : RGWHTTPStreamRWRequest(_cct, _method, _url, _cb, _headers, _params), + http_manager(_cct) { + } + virtual ~RGWRESTStreamRWRequest() override {} + int send_request(RGWAccessKey& key, map& extra_headers, rgw_obj& obj, RGWHTTPManager *mgr = NULL); + int send_request(RGWAccessKey *key, map& extra_headers, const string& resource, bufferlist *send_data = NULL /* optional input data */, RGWHTTPManager *mgr = NULL); + int complete_request(string& etag, real_time *mtime, uint64_t *psize, map& attrs); +}; + class RGWRESTStreamReadRequest : public RGWRESTStreamRWRequest { public: RGWRESTStreamReadRequest(CephContext *_cct, const string& _url, RGWGetDataCB *_cb, param_vec_t *_headers, diff --git a/src/rgw/rgw_rest_conn.cc b/src/rgw/rgw_rest_conn.cc index fa01dcde9861b..0970a252e1307 100644 --- a/src/rgw/rgw_rest_conn.cc +++ b/src/rgw/rgw_rest_conn.cc @@ -109,7 +109,7 @@ int RGWRESTConn::forward(const rgw_user& uid, req_info& info, obj_version *objv, snprintf(buf, sizeof(buf), "%lld", (long long)objv->ver); params.push_back(param_pair_t(RGW_SYS_PARAM_PREFIX "ver", buf)); } - RGWRESTSimpleRequest req(cct, url, NULL, ¶ms); + RGWRESTSimpleRequest req(cct, info.method, url, NULL, ¶ms); return req.forward_request(key, info, max_response, inbl, outbl); } @@ -123,7 +123,7 @@ int RGWRESTConn::put_obj_init(const rgw_user& uid, rgw_obj& obj, uint64_t obj_si param_vec_t params; populate_params(params, &uid, self_zone_group); - RGWRESTStreamWriteRequest *wr = new RGWRESTStreamWriteRequest(cct, url, NULL, ¶ms); + RGWRESTStreamWriteRequest *wr = new RGWRESTStreamWriteRequest(cct, "PUT", url, NULL, ¶ms); ret = wr->put_obj_init(key, obj, obj_size, attrs); if (ret < 0) { delete wr; diff --git a/src/rgw/rgw_swift_auth.cc b/src/rgw/rgw_swift_auth.cc index 9c2e7e33f8b99..4e9b082eaae27 100644 --- a/src/rgw/rgw_swift_auth.cc +++ b/src/rgw/rgw_swift_auth.cc @@ -379,11 +379,11 @@ ExternalTokenEngine::authenticate(const std::string& token, char url_buf[auth_url.size() + 1 + token.length() + 1]; sprintf(url_buf, "%s/%s", auth_url.c_str(), token.c_str()); - RGWHTTPHeadersCollector validator(cct, { "X-Auth-Groups", "X-Auth-Ttl" }); + RGWHTTPHeadersCollector validator(cct, "GET", url_buf, { "X-Auth-Groups", "X-Auth-Ttl" }); ldout(cct, 10) << "rgw_swift_validate_token url=" << url_buf << dendl; - int ret = validator.process(url_buf); + int ret = validator.process(); if (ret < 0) { throw ret; } -- 2.39.5