]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add headers to guide cache update in 304 response to conditional get
authorIlsoo Byun <ilsoobyun@linecorp.com>
Thu, 28 May 2020 08:01:22 +0000 (17:01 +0900)
committerCasey Bodley <cbodley@redhat.com>
Fri, 24 Nov 2023 15:35:53 +0000 (10:35 -0500)
Fixes: https://tracker.ceph.com/issues/45736
Signed-off-by: Ilsoo Byun <ilsoobyun@linecorp.com>
src/rgw/driver/rados/rgw_rados.cc
src/rgw/rgw_rest_s3.cc

index 3ee43dd91a89ceb7fcba3cee0a394684b5aedb97..f7ce93f773b8cc4e983e68f5fbf7c6fda9c0b68e 100644 (file)
@@ -6688,6 +6688,10 @@ int RGWRados::Object::Read::prepare(optional_yield y, const DoutPrefixProvider *
     }
   }
 
+  if (params.lastmod) {
+    *params.lastmod = astate->mtime;
+  }
+
   /* Convert all times go GMT to make them compatible */
   if (conds.mod_ptr || conds.unmod_ptr) {
     obj_time_weight src_weight;
@@ -6738,9 +6742,6 @@ int RGWRados::Object::Read::prepare(optional_yield y, const DoutPrefixProvider *
   if (params.obj_size) {
     *params.obj_size = astate->size;
   }
-  if (params.lastmod) {
-    *params.lastmod = astate->mtime;
-  }
   if (params.epoch) {
     *params.epoch = astate->epoch;
   }
index 5425406b1eb95f8f71d3c5482e265c2b6e3ed680..1ebc0e72127ef5cf1dc6ffda8512013db0b88034 100644 (file)
@@ -579,6 +579,20 @@ done:
   }
 
   if (op_ret == -ERR_NOT_MODIFIED) {
+      dump_last_modified(s, lastmod);
+
+      auto iter = attrs.find(RGW_ATTR_ETAG);
+      if (iter != attrs.end())
+        dump_etag(s, iter->second.to_str());
+
+      iter = attrs.find(RGW_ATTR_CACHE_CONTROL);
+      if (iter != attrs.end())
+        dump_header(s, rgw_to_http_attrs[RGW_ATTR_CACHE_CONTROL], iter->second);
+
+      iter = attrs.find(RGW_ATTR_EXPIRES);
+      if (iter != attrs.end())
+        dump_header(s, rgw_to_http_attrs[RGW_ATTR_EXPIRES], iter->second);
+
       end_header(s, this);
   } else {
       if (!content_type)