traeak commented on code in PR #12092:
URL: https://github.com/apache/trafficserver/pull/12092#discussion_r2000982558
##########
plugins/cache_range_requests/cache_range_requests.cc:
##########
@@ -605,6 +642,60 @@ handle_cache_lookup_complete(TSHttpTxn txnp, txndata
*const txn_state)
}
}
}
+ } else if (TS_CACHE_LOOKUP_HIT_STALE == cachestat &&
txn_state->ident_check) {
+ TSMBuffer resp_buf = nullptr;
+ TSMLoc resp_loc = TS_NULL_MLOC;
+
+ pluginconfig const *const pc = txn_state->config;
+
+ if (TS_SUCCESS == TSHttpTxnCachedRespGet(txnp, &resp_buf, &resp_loc)) {
+ if (TS_HTTP_STATUS_OK == TSHttpHdrStatusGet(resp_buf, resp_loc)) {
+ // get the request identifier
+ TSMBuffer req_buf = nullptr;
+ TSMLoc req_loc = TS_NULL_MLOC;
+ if (TS_SUCCESS == TSHttpTxnClientReqGet(txnp, &req_buf, &req_loc)) {
+ TSMLoc const ident_loc = TSMimeHdrFieldFind(req_buf, req_loc,
pc->ident_header.data(), pc->ident_header.size());
+ if (TS_NULL_MLOC != ident_loc) {
+ DEBUG_LOG("Checking identifier against the '%s' header",
pc->ident_header.c_str());
+
+ int len = 0;
+ char const *const str = TSMimeHdrFieldValueStringGet(req_buf,
req_loc, ident_loc, -1, &len);
+
+ // determine which identifier has been provided
+ std::string_view const svreq(str, len);
+ std::string_view tag;
+ if (svreq.substr(0, Etag.length()) == Etag) {
+ DEBUG_LOG("Etag identifier provided in '%.*s'", len, str);
+ tag = Etag;
+ } else if (svreq.substr(0, LastModified.length()) ==
LastModified) {
+ DEBUG_LOG("Last-Modified indentifier provided in '%.*s'", len,
str);
+ tag = LastModified;
+ }
+
+ if (!tag.empty()) {
+ TSMLoc const id_loc = TSMimeHdrFieldFind(resp_buf, resp_loc,
tag.data(), tag.size());
+ if (TS_NULL_MLOC != id_loc) {
+ int len = 0;
+ char const *const str =
TSMimeHdrFieldValueStringGet(resp_buf, resp_loc, id_loc, 0, &len);
+ std::string_view const sv(str, len);
+
+ DEBUG_LOG("Checking cached '%.*s' against request '%.*s'",
len, str, (int)svreq.size(), svreq.data());
+
+ if (std::string_view::npos != svreq.rfind(sv)) {
Review Comment:
the first requested slice will establish the identifier. so if the first
slice ends up vacating out of cache but a subsequent slice is cached but stale
this should still work as long as the first slice identifier matches the stale
slice's identifier.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]