s->bucket_owner = s->bucket_acl->get_owner();
string& region = s->bucket_info.region;
+ map<string, RGWRegion>::iterator dest_region = store->region_map.regions.find(region);
+ if (dest_region != store->region_map.regions.end()) {
+ s->region_endpoint = dest_region->second.endpoints.front();
+ }
if (s->bucket_exists && !store->region.equals(region)) {
ldout(s->cct, 0) << "NOTICE: request for data in a different region (" << region << " != " << store->region.name << ")" << dendl;
/* we now need to make sure that the operation actually requires copy source, that is
set_req_state_err(s, err_no);
dump_errno(s);
dump_bucket_from_state(s);
+ if (err_no == -ERR_PERMANENT_REDIRECT && !s->region_endpoint.empty()) {
+ string dest_uri = s->region_endpoint;
+ /*
+ * reqest_uri is always start with slash, so we need to remove
+ * the unnecessary slash at the end of dest_uri.
+ */
+ if (dest_uri[dest_uri.size() - 1] == '/') {
+ dest_uri = dest_uri.substr(0, dest_uri.size() - 1);
+ }
+ dest_uri += s->info.request_uri;
+ dest_uri += "?";
+ dest_uri += s->info.request_params;
+
+ dump_redirect(s, dest_uri);
+ }
end_header(s, op);
rgw_flush_formatter_and_reset(s, s->formatter);
perfcounter->inc(l_rgw_failed_req);