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

Function TSRemapDoRemap

plugins/header_rewrite/header_rewrite.cc:550–598  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// This is the main "entry" point for the plugin, called for every request.

Source from the content-addressed store, hash-verified

548// This is the main "entry" point for the plugin, called for every request.
549//
550TSRemapStatus
551TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
552{
553 // Make sure things are properly setup (this should never happen)
554 if (nullptr == ih) {
555 Dbg(pi_dbg_ctl, "No Rules configured, falling back to default");
556 return TSREMAP_NO_REMAP;
557 }
558
559 TSRemapStatus rval = TSREMAP_NO_REMAP;
560 RulesConfig *conf = static_cast<RulesConfig *>(ih);
561
562 // Go through all hooks we support, and setup the txn hook(s) as necessary
563 for (int i = TS_HTTP_READ_REQUEST_HDR_HOOK; i < TS_HTTP_LAST_HOOK; ++i) {
564 if (conf->rule(i)) {
565 TSHttpTxnHookAdd(rh, static_cast<TSHttpHookID>(i), conf->continuation());
566 Dbg(pi_dbg_ctl, "Added remapped TXN hook=%s", TSHttpHookNameLookup(static_cast<TSHttpHookID>(i)));
567 }
568 }
569
570 // Now handle the remap specific rules for the "remap hook" (which is not a real hook).
571 // This is sufficiently different than the normal cont_rewrite_headers() callback, and
572 // we can't (shouldn't) schedule this as a TXN hook.
573 RuleSet *rule = conf->rule(TS_REMAP_PSEUDO_HOOK);
574 Resources res(rh, rri);
575
576 if (rule) {
577 res.gather(conf->resid(TS_REMAP_PSEUDO_HOOK), TS_REMAP_PSEUDO_HOOK);
578
579 do {
580 const RuleSet::OperatorPair &ops = rule->eval(res);
581 const OperModifiers rt = rule->exec(ops, res);
582
583 ink_assert((rt & OPER_NO_REENABLE) == 0);
584
585 if (res.changed_url == true) {
586 rval = TSREMAP_DID_REMAP;
587 }
588
589 if (rule->last() || (rt & OPER_LAST)) {
590 break; // Conditional break, force a break with [L]
591 }
592
593 } while ((rule = rule->next));
594 }
595
596 Dbg(dbg_ctl, "Returning from TSRemapDoRemap with status: %d", rval);
597 return rval;
598}

Callers

nothing calls this directly

Calls 9

TSHttpTxnHookAddFunction · 0.85
TSHttpHookNameLookupFunction · 0.85
ruleMethod · 0.80
gatherMethod · 0.80
residMethod · 0.80
continuationMethod · 0.45
evalMethod · 0.45
execMethod · 0.45
lastMethod · 0.45

Tested by

no test coverage detected