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

Function globalHookHandler

plugins/esi/esi.cc:1518–1578  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1516}
1517
1518static int
1519globalHookHandler(TSCont contp, TSEvent event, void *edata)
1520{
1521 TSHttpTxn txnp = static_cast<TSHttpTxn>(edata);
1522 bool intercept_header = false;
1523 bool head_only = false;
1524 bool intercept_req = isInterceptRequest(txnp);
1525 struct OptionInfo *pOptionInfo = static_cast<OptionInfo *>(TSContDataGet(contp));
1526
1527 switch (event) {
1528 case TS_EVENT_HTTP_READ_REQUEST_HDR:
1529 Dbg(dbg_ctl_local, "[%s] handling read request header event", __FUNCTION__);
1530 if (intercept_req) {
1531 if (!setupServerIntercept(txnp)) {
1532 TSError("[esi][%s] Could not setup server intercept", __FUNCTION__);
1533 } else {
1534 Dbg(dbg_ctl_local, "[%s] Setup server intercept", __FUNCTION__);
1535 }
1536 } else {
1537 Dbg(dbg_ctl_local, "[%s] Not setting up intercept", __FUNCTION__);
1538 }
1539 break;
1540
1541 case TS_EVENT_HTTP_READ_RESPONSE_HDR:
1542 case TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE:
1543 if (!intercept_req) {
1544 if (event == TS_EVENT_HTTP_READ_RESPONSE_HDR) {
1545 bool mask_cache_headers = false;
1546 Dbg(dbg_ctl_local, "[%s] handling read response header event", __FUNCTION__);
1547 if (isTxnTransformable(txnp, false, pOptionInfo, &intercept_header, &head_only)) {
1548 addTransform(txnp, true, intercept_header, head_only, pOptionInfo);
1549 Stats::increment(Stats::N_OS_DOCS);
1550 mask_cache_headers = true;
1551 }
1552 if (pOptionInfo->packed_node_support && mask_cache_headers) {
1553 // we'll 'mask' OS cache headers so that traffic server will
1554 // not try to cache this. We cannot outright delete them
1555 // because we need them in our POST request; hence the 'masking'
1556 maskOsCacheHeaders(txnp);
1557 }
1558 } else {
1559 Dbg(dbg_ctl_local, "[%s] handling cache lookup complete event", __FUNCTION__);
1560 if (isCacheObjTransformable(txnp, pOptionInfo, &intercept_header, &head_only)) {
1561 // we make the assumption above that a transformable cache
1562 // object would already have a transformation. We should revisit
1563 // that assumption in case we change the statement below
1564 addTransform(txnp, false, intercept_header, head_only, pOptionInfo);
1565 Stats::increment(Stats::N_CACHE_DOCS);
1566 }
1567 }
1568 }
1569 break;
1570
1571 default:
1572 Dbg(dbg_ctl_local, "[%s] Don't know how to handle event type %d", __FUNCTION__, event);
1573 break;
1574 }
1575

Callers

nothing calls this directly

Calls 10

isInterceptRequestFunction · 0.85
TSContDataGetFunction · 0.85
setupServerInterceptFunction · 0.85
isTxnTransformableFunction · 0.85
addTransformFunction · 0.85
incrementFunction · 0.85
maskOsCacheHeadersFunction · 0.85
isCacheObjTransformableFunction · 0.85
TSHttpTxnReenableFunction · 0.85
TSErrorFunction · 0.50

Tested by

no test coverage detected