Skip to content

Commit 7e3d7fa

Browse files
authored
if transaction status non-success, bypass intercept plugin (apache#7724)
Don't allow the generator or statichit plugin to intercept the transaction if a prior plugin has changed the transaction status to something non-success. (plus cleanup)
1 parent 9436559 commit 7e3d7fa

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

plugins/experimental/slice/slice.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ read_request(TSHttpTxn txnp, Config *const config)
4646
if (!header.hasKey(SLICER_MIME_FIELD_INFO, SLICER_MIME_LEN_INFO)) {
4747
// check if any previous plugin has monkeyed with the transaction status
4848
TSHttpStatus const txnstat = TSHttpTxnStatusGet(txnp);
49-
if (0 != static_cast<int>(txnstat)) {
50-
DEBUG_LOG("txn status change detected (%d), skipping plugin\n", (int)txnstat);
49+
if (TS_HTTP_STATUS_NONE != txnstat) {
50+
DEBUG_LOG("txn status change detected (%d), skipping plugin\n", static_cast<int>(txnstat));
5151
return false;
5252
}
5353

plugins/experimental/statichit/statichit.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,12 @@ TSRemapInit(TSRemapInterface * /* api_info */, char * /* errbuf */, int /* errbu
563563
TSRemapStatus
564564
TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
565565
{
566+
const TSHttpStatus txnstat = TSHttpTxnStatusGet(rh);
567+
if (txnstat != TS_HTTP_STATUS_NONE && txnstat != TS_HTTP_STATUS_OK) {
568+
VDEBUG("transaction status_code=%d already set; skipping processing", static_cast<int>(txnstat));
569+
return TSREMAP_NO_REMAP;
570+
}
571+
566572
StaticHitConfig *cfg = static_cast<StaticHitConfig *>(ih);
567573

568574
if (!cfg) {

plugins/generator/generator.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,12 @@ TSRemapInit(TSRemapInterface * /* api_info */, char * /* errbuf */, int /* errbu
732732
TSRemapStatus
733733
TSRemapDoRemap(void * /* ih */, TSHttpTxn txn, TSRemapRequestInfo *rri)
734734
{
735+
const TSHttpStatus txnstat = TSHttpTxnStatusGet(txn);
736+
if (txnstat != TS_HTTP_STATUS_NONE && txnstat != TS_HTTP_STATUS_OK) {
737+
VDEBUG("transaction status_code=%d already set; skipping processing", static_cast<int>(txnstat));
738+
return TSREMAP_NO_REMAP;
739+
}
740+
735741
// Check if we should turn off the cache before doing anything else ...
736742
CheckCacheable(txn, rri->requestUrl, rri->requestBufp);
737743
TSHttpTxnHookAdd(txn, TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, TxnHook);

0 commit comments

Comments
 (0)