}
#define MAX_REST_RESPONSE (128 * 1024) // we expect a very small response
-static int send_to_remote_gateway(const string& remote, req_info& info,
+static int send_to_remote_gateway(RGWRESTConn* conn, req_info& info,
bufferlist& in_data, JSONParser& parser)
{
bufferlist response;
- RGWRESTConn *conn;
- if (remote.empty()) {
- if (!store->rest_master_conn) {
- cerr << "Invalid rest master connection" << std::endl;
- return -EINVAL;
- }
- conn = store->rest_master_conn;
- } else {
- // check zonegroups
- auto iter = store->zonegroup_conn_map.find(remote);
- if (iter == store->zonegroup_conn_map.end()) {
- // check zones
- iter = store->zone_conn_map.find(remote);
- if (iter == store->zone_conn_map.end()) {
- cerr << "could not find connection for zone or zonegroup id: "
- << remote << std::endl;
- return -ENOENT;
- }
- }
- conn = iter->second;
- }
rgw_user user;
int ret = conn->forward(user, info, NULL, MAX_REST_RESPONSE, &in_data, &response);
return ret;
}
-static int send_to_remote_or_url(const string& remote, const string& url,
+static int send_to_remote_or_url(RGWRESTConn *conn, const string& url,
const string& access, const string& secret,
req_info& info, bufferlist& in_data,
JSONParser& parser)
{
if (url.empty()) {
- return send_to_remote_gateway(remote, info, in_data, parser);
+ return send_to_remote_gateway(conn, info, in_data, parser);
}
return send_to_url(url, access, secret, info, in_data, parser);
}
jf.flush(bl);
JSONParser p;
- int ret = send_to_remote_or_url(remote, url, access, secret, info, bl, p);
+ int ret = send_to_remote_or_url(nullptr, url, access, secret, info, bl, p);
if (ret < 0) {
cerr << "request failed: " << cpp_strerror(-ret) << std::endl;
bufferlist bl;
JSONParser p;
- int ret = send_to_remote_or_url(remote, url, access_key, secret_key,
+ int ret = send_to_remote_or_url(nullptr, url, access_key, secret_key,
info, bl, p);
if (ret < 0) {
cerr << "request failed: " << cpp_strerror(-ret) << std::endl;
jf.flush(bl);
JSONParser p;
- ret = send_to_remote_or_url(remote, url, access_key, secret_key,
+ ret = send_to_remote_or_url(nullptr, url, access_key, secret_key,
info, bl, p);
if (ret < 0) {
cerr << "request failed: " << cpp_strerror(-ret) << std::endl;