MCPcopy Create free account
hub / github.com/apache/trafficserver / bgFetchAllowed

Method bgFetchAllowed

plugins/experimental/cache_fill/configs.cc:202–243  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////// Check the configuration (either per remap, or global), and decide if this request is allowed to trigger a background fetch.

Source from the content-addressed store, hash-verified

200// this request is allowed to trigger a background fetch.
201//
202bool
203BgFetchConfig::bgFetchAllowed(TSHttpTxn txnp) const
204{
205 Dbg(dbg_ctl, "Testing: request is internal?");
206 if (TSHttpTxnIsInternal(txnp)) {
207 return false;
208 }
209
210 if (_range_req_only || !_cache_range_req) {
211 TSMBuffer bufp;
212 TSMLoc hdr_loc;
213 if (TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc) == TS_SUCCESS) {
214 bool hasRangeHdrs = false;
215 for (auto const &header : FILTER_HEADERS) {
216 if (TSMimeHdrFieldFind(bufp, hdr_loc, header.data(), header.size() == TS_SUCCESS)) {
217 hasRangeHdrs = true;
218 break;
219 }
220 }
221 if (!hasRangeHdrs && _range_req_only) {
222 Dbg(dbg_ctl, "_range_req_only=true; This transaction is not a range request");
223 return false;
224 }
225 if (hasRangeHdrs && !_cache_range_req) {
226 Dbg(dbg_ctl, "_cache_range_req=false; This transaction is a range request");
227 return false;
228 }
229 }
230 }
231
232 bool allow_bg_fetch = true;
233 // We could do this recursively, but following the linked list is probably more efficient.
234 for (auto const &r : _rules) {
235 if (r.check_field_configured(txnp)) {
236 Dbg(dbg_ctl, "found %s rule match", r._exclude ? "exclude" : "include");
237 allow_bg_fetch = !r._exclude;
238 break;
239 }
240 }
241
242 return allow_bg_fetch;
243}

Callers 1

cont_handle_cacheFunction · 0.45

Calls 6

TSHttpTxnIsInternalFunction · 0.85
TSHttpTxnClientReqGetFunction · 0.85
TSMimeHdrFieldFindFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected