Skip to content

Commit beba28f

Browse files
committed
rgw: add wildcard "*" support for conditional read
- Enhanced If-Match and If-None-Match headers to support the wildcard "*". - Updated conditional read behavior: - If-Match: * now returns 200 instead of 412 when any object exists. - If-None-Match: * now returns 304 instead of 200 when any object exists. - If-Match: * + If-None-Match: * now returns 304 instead of 412. - Aligns with AWS S3 expected functionality for improved efficiency. Signed-off-by: sungjoon_koh <[email protected]>
1 parent 7b5fe62 commit beba28f

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/rgw/driver/dbstore/common/dbstore.cc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,14 +1381,22 @@ int DB::Object::Read::prepare(const DoutPrefixProvider *dpp)
13811381

13821382
if (conds.if_match) {
13831383
string if_match_str = rgw_string_unquote(conds.if_match);
1384-
ldpp_dout(dpp, 10) << "ETag: " << string(etag.c_str(), etag.length()) << " " << " If-Match: " << if_match_str << dendl;
1385-
if (if_match_str.compare(0, etag.length(), etag.c_str(), etag.length()) != 0) {
1386-
return -ERR_PRECONDITION_FAILED;
1384+
if (if_match_str.compare("*") != 0) {
1385+
ldpp_dout(dpp, 10) << "ETag: " << string(etag.c_str(), etag.length()) << " " << " If-Match: " << if_match_str << dendl;
1386+
if (if_match_str.compare(0, etag.length(), etag.c_str(), etag.length()) != 0) {
1387+
return -ERR_PRECONDITION_FAILED;
1388+
}
1389+
} else {
1390+
ldpp_dout(dpp, 10) << "If-Match: " << if_match_str << dendl;
13871391
}
13881392
}
13891393

13901394
if (conds.if_nomatch) {
13911395
string if_nomatch_str = rgw_string_unquote(conds.if_nomatch);
1396+
if (if_nomatch_str.compare("*") == 0) {
1397+
ldpp_dout(dpp, 10) << "If-NoMatch: " << if_nomatch_str << dendl;
1398+
return -ERR_NOT_MODIFIED;
1399+
}
13921400
ldpp_dout(dpp, 10) << "ETag: " << string(etag.c_str(), etag.length()) << " " << " If-NoMatch: " << if_nomatch_str << dendl;
13931401
if (if_nomatch_str.compare(0, etag.length(), etag.c_str(), etag.length()) == 0) {
13941402
return -ERR_NOT_MODIFIED;

src/rgw/driver/rados/rgw_rados.cc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7745,14 +7745,22 @@ int RGWRados::Object::Read::prepare(optional_yield y, const DoutPrefixProvider *
77457745

77467746
if (conds.if_match) {
77477747
string if_match_str = rgw_string_unquote(conds.if_match);
7748-
ldpp_dout(dpp, 10) << "ETag: " << string(etag.c_str(), etag.length()) << " " << " If-Match: " << if_match_str << dendl;
7749-
if (if_match_str.compare(0, etag.length(), etag.c_str(), etag.length()) != 0) {
7750-
return -ERR_PRECONDITION_FAILED;
7748+
if (if_match_str.compare("*") != 0) {
7749+
ldpp_dout(dpp, 10) << "ETag: " << string(etag.c_str(), etag.length()) << " " << " If-Match: " << if_match_str << dendl;
7750+
if (if_match_str.compare(0, etag.length(), etag.c_str(), etag.length()) != 0) {
7751+
return -ERR_PRECONDITION_FAILED;
7752+
}
7753+
} else {
7754+
ldpp_dout(dpp, 10) << "If-Match: " << if_match_str << dendl;
77517755
}
77527756
}
77537757

77547758
if (conds.if_nomatch) {
77557759
string if_nomatch_str = rgw_string_unquote(conds.if_nomatch);
7760+
if (if_nomatch_str.compare("*") == 0) {
7761+
ldpp_dout(dpp, 10) << "If-NoMatch: " << if_nomatch_str << dendl;
7762+
return -ERR_NOT_MODIFIED;
7763+
}
77567764
ldpp_dout(dpp, 10) << "ETag: " << string(etag.c_str(), etag.length()) << " " << " If-NoMatch: " << if_nomatch_str << dendl;
77577765
if (if_nomatch_str.compare(0, etag.length(), etag.c_str(), etag.length()) == 0) {
77587766
return -ERR_NOT_MODIFIED;

0 commit comments

Comments
 (0)