#define dout_subsys ceph_subsys_rgw
+using namespace std;
+
RGWRESTConn::RGWRESTConn(CephContext *_cct, RGWSI_Zone *zone_svc,
const string& _remote_id,
const list<string>& remote_endpoints,
+ std::optional<string> _api_name,
HostStyle _host_style)
: cct(_cct),
endpoints(remote_endpoints.begin(), remote_endpoints.end()),
- remote_id(_remote_id), host_style(_host_style)
+ remote_id(_remote_id),
+ api_name(_api_name),
+ host_style(_host_style)
{
if (zone_svc) {
key = zone_svc->get_zone_params().system_key;
}
}
+RGWRESTConn::RGWRESTConn(CephContext *_cct, rgw::sal::Store* store,
+ const string& _remote_id,
+ const list<string>& remote_endpoints,
+ std::optional<string> _api_name,
+ HostStyle _host_style)
+ : cct(_cct),
+ endpoints(remote_endpoints.begin(), remote_endpoints.end()),
+ remote_id(_remote_id),
+ api_name(_api_name),
+ host_style(_host_style)
+{
+ if (store) {
+ key = store->get_zone()->get_params().system_key;
+ self_zone_group = store->get_zone()->get_zonegroup().get_id();
+ }
+}
+
RGWRESTConn::RGWRESTConn(CephContext *_cct, RGWSI_Zone *zone_svc,
const string& _remote_id,
const list<string>& remote_endpoints,
RGWAccessKey _cred,
+ std::optional<string> _api_name,
HostStyle _host_style)
: cct(_cct),
endpoints(remote_endpoints.begin(), remote_endpoints.end()),
key(std::move(_cred)),
- remote_id(_remote_id), host_style(_host_style)
+ remote_id(_remote_id),
+ api_name(_api_name),
+ host_style(_host_style)
{
if (zone_svc) {
self_zone_group = zone_svc->get_zonegroup().get_id();
}
}
+RGWRESTConn::RGWRESTConn(CephContext *_cct, rgw::sal::Store* store,
+ const string& _remote_id,
+ const list<string>& remote_endpoints,
+ RGWAccessKey _cred,
+ std::optional<string> _api_name,
+ HostStyle _host_style)
+ : cct(_cct),
+ endpoints(remote_endpoints.begin(), remote_endpoints.end()),
+ key(std::move(_cred)),
+ remote_id(_remote_id),
+ api_name(_api_name),
+ host_style(_host_style)
+{
+ if (store) {
+ self_zone_group = store->get_zone()->get_zonegroup().get_id();
+ }
+}
+
RGWRESTConn::RGWRESTConn(RGWRESTConn&& other)
: cct(other.cct),
endpoints(std::move(other.endpoints)),
snprintf(buf, sizeof(buf), "%lld", (long long)objv->ver);
params.push_back(param_pair_t(RGW_SYS_PARAM_PREFIX "ver", buf));
}
- RGWRESTSimpleRequest req(cct, info.method, url, NULL, ¶ms);
+ RGWRESTSimpleRequest req(cct, info.method, url, NULL, ¶ms, api_name);
return req.forward_request(dpp, key, info, max_response, inbl, outbl, y);
}
-class StreamObjData : public RGWGetDataCB {
- rgw_obj obj;
-public:
- explicit StreamObjData(rgw_obj& _obj) : obj(_obj) {}
-};
-
-int RGWRESTConn::put_obj_send_init(rgw::sal::RGWObject* obj, const rgw_http_param_pair *extra_params, RGWRESTStreamS3PutObj **req)
+int RGWRESTConn::put_obj_send_init(rgw::sal::Object* obj, const rgw_http_param_pair *extra_params, RGWRESTStreamS3PutObj **req)
{
string url;
int ret = get_url(url);
append_param_list(params, extra_params);
}
- RGWRESTStreamS3PutObj *wr = new RGWRESTStreamS3PutObj(cct, "PUT", url, NULL, ¶ms, host_style);
+ RGWRESTStreamS3PutObj *wr = new RGWRESTStreamS3PutObj(cct, "PUT", url, NULL, ¶ms, api_name, host_style);
wr->send_init(obj);
*req = wr;
return 0;
}
-int RGWRESTConn::put_obj_async(const DoutPrefixProvider *dpp,
- const rgw_user& uid, rgw::sal::RGWObject* obj, uint64_t obj_size,
- map<string, bufferlist>& attrs, bool send,
- RGWRESTStreamS3PutObj **req)
+int RGWRESTConn::put_obj_async_init(const DoutPrefixProvider *dpp, const rgw_user& uid, rgw::sal::Object* obj,
+ map<string, bufferlist>& attrs,
+ RGWRESTStreamS3PutObj **req)
{
string url;
int ret = get_url(url);
param_vec_t params;
populate_params(params, &uid, self_zone_group);
- RGWRESTStreamS3PutObj *wr = new RGWRESTStreamS3PutObj(cct, "PUT", url, NULL, ¶ms, host_style);
- ret = wr->put_obj_init(dpp, key, obj, obj_size, attrs, send);
- if (ret < 0) {
- delete wr;
- return ret;
- }
+ RGWRESTStreamS3PutObj *wr = new RGWRESTStreamS3PutObj(cct, "PUT", url, NULL, ¶ms, api_name, host_style);
+ wr->put_obj_init(dpp, key, obj, attrs);
*req = wr;
return 0;
}
}
-int RGWRESTConn::get_obj(const DoutPrefixProvider *dpp, const rgw_user& uid, req_info *info /* optional */, const rgw::sal::RGWObject* obj,
+int RGWRESTConn::get_obj(const DoutPrefixProvider *dpp, const rgw_user& uid, req_info *info /* optional */, const rgw::sal::Object* obj,
const real_time *mod_ptr, const real_time *unmod_ptr,
uint32_t mod_zone_id, uint64_t mod_pg_ver,
bool prepend_metadata, bool get_op, bool rgwx_stat,
return get_obj(dpp, obj, params, send, req);
}
-int RGWRESTConn::get_obj(const DoutPrefixProvider *dpp, const rgw::sal::RGWObject* obj, const get_obj_params& in_params, bool send, RGWRESTStreamRWRequest **req)
+int RGWRESTConn::get_obj(const DoutPrefixProvider *dpp, const rgw::sal::Object* obj, const get_obj_params& in_params, bool send, RGWRESTStreamRWRequest **req)
{
string url;
int ret = get_url(url);
params.push_back(param_pair_t("versionId", instance));
}
if (in_params.get_op) {
- *req = new RGWRESTStreamReadRequest(cct, url, in_params.cb, NULL, ¶ms, host_style);
+ *req = new RGWRESTStreamReadRequest(cct, url, in_params.cb, NULL, ¶ms, api_name, host_style);
} else {
- *req = new RGWRESTStreamHeadRequest(cct, url, in_params.cb, NULL, ¶ms);
+ *req = new RGWRESTStreamHeadRequest(cct, url, in_params.cb, NULL, ¶ms, api_name);
}
map<string, string> extra_headers;
if (in_params.info) {
RGWStreamIntoBufferlist cb(bl);
- RGWRESTStreamReadRequest req(cct, url, &cb, NULL, ¶ms, host_style);
+ RGWRESTStreamReadRequest req(cct, url, &cb, NULL, ¶ms, api_name, host_style);
map<string, string> headers;
if (extra_headers) {
return req.complete_request(y);
}
+int RGWRESTConn::send_resource(const DoutPrefixProvider *dpp, const std::string& method,
+ const std::string& resource, rgw_http_param_pair *extra_params,
+ std::map<std::string, std::string> *extra_headers, bufferlist& bl,
+ bufferlist *send_data, RGWHTTPManager *mgr, optional_yield y)
+{
+ std::string url;
+ int ret = get_url(url);
+ if (ret < 0)
+ return ret;
+
+ param_vec_t params;
+
+ if (extra_params) {
+ params = make_param_list(extra_params);
+ }
+
+ populate_params(params, nullptr, self_zone_group);
+
+ RGWStreamIntoBufferlist cb(bl);
+
+ RGWRESTStreamSendRequest req(cct, method, url, &cb, NULL, ¶ms, api_name, host_style);
+
+ std::map<std::string, std::string> headers;
+ if (extra_headers) {
+ headers.insert(extra_headers->begin(), extra_headers->end());
+ }
+
+ ret = req.send_request(dpp, &key, headers, resource, mgr, send_data);
+ if (ret < 0) {
+ ldpp_dout(dpp, 5) << __func__ << ": send_request() resource=" << resource << " returned ret=" << ret << dendl;
+ return ret;
+ }
+
+ return req.complete_request(y);
+}
+
RGWRESTReadResource::RGWRESTReadResource(RGWRESTConn *_conn,
const string& _resource,
const rgw_http_param_pair *pp,
RGWHTTPManager *_mgr)
: cct(_conn->get_ctx()), conn(_conn), resource(_resource),
params(make_param_list(pp)), cb(bl), mgr(_mgr),
- req(cct, conn->get_url(), &cb, NULL, NULL)
+ req(cct, conn->get_url(), &cb, NULL, NULL, _conn->get_api_name())
{
init_common(extra_headers);
}
param_vec_t *extra_headers,
RGWHTTPManager *_mgr)
: cct(_conn->get_ctx()), conn(_conn), resource(_resource), params(_params),
- cb(bl), mgr(_mgr), req(cct, conn->get_url(), &cb, NULL, NULL)
+ cb(bl), mgr(_mgr), req(cct, conn->get_url(), &cb, NULL, NULL, _conn->get_api_name())
{
init_common(extra_headers);
}
RGWHTTPManager *_mgr)
: cct(_conn->get_ctx()), conn(_conn), method(_method), resource(_resource),
params(make_param_list(pp)), cb(bl), mgr(_mgr),
- req(cct, method.c_str(), conn->get_url(), &cb, NULL, NULL, _conn->get_host_style())
+ req(cct, method.c_str(), conn->get_url(), &cb, NULL, NULL, _conn->get_api_name(), _conn->get_host_style())
{
init_common(extra_headers);
}
param_vec_t *extra_headers,
RGWHTTPManager *_mgr)
: cct(_conn->get_ctx()), conn(_conn), method(_method), resource(_resource), params(params),
- cb(bl), mgr(_mgr), req(cct, method.c_str(), conn->get_url(), &cb, NULL, NULL, _conn->get_host_style())
+ cb(bl), mgr(_mgr), req(cct, method.c_str(), conn->get_url(), &cb, NULL, NULL, _conn->get_api_name(), _conn->get_host_style())
{
init_common(extra_headers);
}