From: Ilsoo Byun Date: Thu, 28 May 2020 08:01:22 +0000 (+0900) Subject: rgw: add headers to guide cache update in 304 response to conditional get X-Git-Tag: v18.2.4~209^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d5f0eab18e4053a3ce319edac63ced74fac9d2f5;p=ceph.git rgw: add headers to guide cache update in 304 response to conditional get Fixes: https://tracker.ceph.com/issues/45736 Signed-off-by: Ilsoo Byun (cherry picked from commit ca222e47defb06352041da7980fdef508729c4b2) Conflicts: src/rgw/driver/rados/rgw_rados.cc no params.epoch --- diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index 10018d4a68a0..5069233705d2 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -6308,6 +6308,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; @@ -6357,8 +6361,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; return 0; } diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 0b997f30b10e..38e973f7af1c 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -563,6 +563,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)