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

Function cont_rewrite_headers

plugins/header_rewrite/header_rewrite.cc:315–380  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// Continuation

Source from the content-addressed store, hash-verified

313// Continuation
314//
315static int
316cont_rewrite_headers(TSCont contp, TSEvent event, void *edata)
317{
318 TSHttpTxn txnp = static_cast<TSHttpTxn>(edata);
319 TSHttpHookID hook = TS_HTTP_LAST_HOOK;
320 RulesConfig *conf = static_cast<RulesConfig *>(TSContDataGet(contp));
321
322 switch (event) {
323 case TS_EVENT_HTTP_READ_RESPONSE_HDR:
324 hook = TS_HTTP_READ_RESPONSE_HDR_HOOK;
325 break;
326 case TS_EVENT_HTTP_READ_REQUEST_HDR:
327 hook = TS_HTTP_READ_REQUEST_HDR_HOOK;
328 break;
329 case TS_EVENT_HTTP_READ_REQUEST_PRE_REMAP:
330 hook = TS_HTTP_PRE_REMAP_HOOK;
331 break;
332 case TS_EVENT_HTTP_SEND_REQUEST_HDR:
333 hook = TS_HTTP_SEND_REQUEST_HDR_HOOK;
334 break;
335 case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
336 hook = TS_HTTP_SEND_RESPONSE_HDR_HOOK;
337 break;
338 case TS_EVENT_HTTP_TXN_START:
339 hook = TS_HTTP_TXN_START_HOOK;
340 break;
341 case TS_EVENT_HTTP_TXN_CLOSE:
342 hook = TS_HTTP_TXN_CLOSE_HOOK;
343 break;
344 default:
345 TSError("[%s] unknown event for this plugin", PLUGIN_NAME);
346 Dbg(pi_dbg_ctl, "unknown event for this plugin");
347 break;
348 }
349
350 bool reenable{true};
351
352 if (hook != TS_HTTP_LAST_HOOK) {
353 RuleSet *rule = conf->rule(hook);
354 Resources res(txnp, contp);
355
356 // Get the resources necessary to process this event
357 res.gather(conf->resid(hook), hook);
358
359 // Evaluation of all rules. This code is sort of duplicate in DoRemap as well.
360 while (rule) {
361 const RuleSet::OperatorPair &ops = rule->eval(res);
362 const OperModifiers rt = rule->exec(ops, res);
363
364 if (rt & OPER_NO_REENABLE) {
365 reenable = false;
366 }
367
368 if (rule->last() || (rt & OPER_LAST)) {
369 break; // Conditional break, force a break with [L]
370 }
371 rule = rule->next;
372 }

Callers

nothing calls this directly

Calls 9

TSContDataGetFunction · 0.85
TSHttpTxnReenableFunction · 0.85
ruleMethod · 0.80
gatherMethod · 0.80
residMethod · 0.80
TSErrorFunction · 0.70
evalMethod · 0.45
execMethod · 0.45
lastMethod · 0.45

Tested by

no test coverage detected