]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: Fix virtual-hosted style URL
authorSoumya Koduri <skoduri@redhat.com>
Mon, 27 Oct 2025 05:54:25 +0000 (11:24 +0530)
committerSoumya Koduri <skoduri@redhat.com>
Mon, 10 Nov 2025 17:06:21 +0000 (22:36 +0530)
if the host_style is set to "Virtual", the endpoint URL and
host should be set to "<bucket_name>.host" while sending
requests.

Resolves: rhbz#2402662

Signed-off-by: Soumya Koduri <skoduri@redhat.com>
(cherry picked from commit a3cba0372126b2e99ffbe46d729a8867754baa71)

src/rgw/rgw_rest_client.cc

index b2b076e9cfcc856f9aef1abccf8b7bd66d52ba65..399b9c092c9c0e903fd28a85d5f63d803262fdca 100644 (file)
@@ -706,7 +706,7 @@ void RGWRESTStreamS3PutObj::send_init(const rgw_obj& obj)
   if (host_style == VirtualStyle) {
     resource_str = obj.get_oid();
 
-    new_url = bucket_name + "."  + new_url;
+    new_url = protocol + "://" + bucket_name + "." + host;
     new_host = bucket_name + "." + new_host;
   } else {
     resource_str = bucket_name + "/" + obj.get_oid();
@@ -718,6 +718,8 @@ void RGWRESTStreamS3PutObj::send_init(const rgw_obj& obj)
   if (new_url[new_url.size() - 1] != '/')
     new_url.append("/");
 
+  ldpp_dout(this, 20) << __func__ << "(): host = " << host << " , resource = " << resource << " , new_host = " << new_host << " , new_url = " << new_url  << dendl;
+
   method = "PUT";
   headers_gen.init(method, new_host, resource_prefix, new_url, resource, params, api_name);
 
@@ -843,6 +845,7 @@ int RGWRESTStreamRWRequest::do_send_prepare(const DoutPrefixProvider *dpp, RGWAc
   string new_resource;
   string bucket_name;
   string old_resource = resource;
+  string new_host = host;
 
   if (resource[0] == '/') {
     new_resource = resource.substr(1);
@@ -865,11 +868,17 @@ int RGWRESTStreamRWRequest::do_send_prepare(const DoutPrefixProvider *dpp, RGWAc
     } else {
       new_resource = new_resource.substr(pos+1);
     }
+    new_host = bucket_name + "." + host;
   }
 
+  if (new_url[new_url.size() - 1] != '/')
+    new_url.append("/");
+
   headers_gen.emplace(cct, &new_env, &new_info);
 
-  headers_gen->init(method, host, resource_prefix, new_url, new_resource, params, api_name);
+  ldpp_dout(this, 20) << __func__ << "(): host = " << host << " , resource = " << resource << " , new_host = " << new_host << " , new_url = " << new_url  << " , new_resource = " << new_resource << dendl;
+
+  headers_gen->init(method, new_host, resource_prefix, new_url, new_resource, params, api_name);
 
   headers_gen->set_http_attrs(extra_headers);