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: v19.3.0~267^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ca222e47defb06352041da7980fdef508729c4b2;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 --- diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index 3ee43dd91a8..f7ce93f773b 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -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; } diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 5425406b1eb..1ebc0e72127 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -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)