Skip to content

Commit f872a2c

Browse files
authored
Merge pull request ceph#54587 from cbodley/wip-45736
rgw: add headers to guide cache update in 304 response Reviewed-by: Yuval Lifshitz <[email protected]>
2 parents e2874ef + ccd241c commit f872a2c

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

src/rgw/driver/rados/rgw_rados.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6689,6 +6689,10 @@ int RGWRados::Object::Read::prepare(optional_yield y, const DoutPrefixProvider *
66896689
}
66906690
}
66916691

6692+
if (params.lastmod) {
6693+
*params.lastmod = astate->mtime;
6694+
}
6695+
66926696
/* Convert all times go GMT to make them compatible */
66936697
if (conds.mod_ptr || conds.unmod_ptr) {
66946698
obj_time_weight src_weight;
@@ -6739,9 +6743,6 @@ int RGWRados::Object::Read::prepare(optional_yield y, const DoutPrefixProvider *
67396743
if (params.obj_size) {
67406744
*params.obj_size = astate->size;
67416745
}
6742-
if (params.lastmod) {
6743-
*params.lastmod = astate->mtime;
6744-
}
67456746
if (params.epoch) {
67466747
*params.epoch = astate->epoch;
67476748
}

src/rgw/rgw_op.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,12 +2275,12 @@ void RGWGetObj::execute(optional_yield y)
22752275
}
22762276

22772277
op_ret = read_op->prepare(s->yield, this);
2278-
if (op_ret < 0)
2279-
goto done_err;
22802278
version_id = s->object->get_instance();
22812279
s->obj_size = s->object->get_obj_size();
22822280
attrs = s->object->get_attrs();
22832281
multipart_parts_count = read_op->params.parts_count;
2282+
if (op_ret < 0)
2283+
goto done_err;
22842284

22852285
/* STAT ops don't need data, and do no i/o */
22862286
if (get_type() == RGW_OP_STAT_OBJ) {

src/rgw/rgw_rest_s3.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,20 @@ int RGWGetObj_ObjStore_S3::send_response_data(bufferlist& bl, off_t bl_ofs,
579579
}
580580

581581
if (op_ret == -ERR_NOT_MODIFIED) {
582+
dump_last_modified(s, lastmod);
583+
584+
auto iter = attrs.find(RGW_ATTR_ETAG);
585+
if (iter != attrs.end())
586+
dump_etag(s, iter->second.to_str());
587+
588+
iter = attrs.find(RGW_ATTR_CACHE_CONTROL);
589+
if (iter != attrs.end())
590+
dump_header(s, rgw_to_http_attrs[RGW_ATTR_CACHE_CONTROL], iter->second);
591+
592+
iter = attrs.find(RGW_ATTR_EXPIRES);
593+
if (iter != attrs.end())
594+
dump_header(s, rgw_to_http_attrs[RGW_ATTR_EXPIRES], iter->second);
595+
582596
end_header(s, this);
583597
} else {
584598
if (!content_type)

0 commit comments

Comments
 (0)