| 7940 | /**** Append Transform Code Ends ****/ |
| 7941 | |
| 7942 | static int |
| 7943 | transform_hook_handler(TSCont contp, TSEvent event, void *edata) |
| 7944 | { |
| 7945 | TSHttpTxn txnp = nullptr; |
| 7946 | TransformTestData *data = nullptr; |
| 7947 | |
| 7948 | CHECK_SPURIOUS_EVENT(contp, event, edata); |
| 7949 | data = static_cast<TransformTestData *>(TSContDataGet(contp)); |
| 7950 | |
| 7951 | switch (event) { |
| 7952 | case TS_EVENT_HTTP_READ_REQUEST_HDR: |
| 7953 | txnp = static_cast<TSHttpTxn>(edata); |
| 7954 | TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_SKIP_REMAPPING, true); |
| 7955 | TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE); |
| 7956 | break; |
| 7957 | case TS_EVENT_HTTP_READ_RESPONSE_HDR: |
| 7958 | txnp = static_cast<TSHttpTxn>(edata); |
| 7959 | /* Setup hooks for Transformation */ |
| 7960 | if (transformable(txnp, data)) { |
| 7961 | transform_add(txnp, data); |
| 7962 | } |
| 7963 | /* Call TransformedRespCache or UntransformedRespCache depending on request */ |
| 7964 | { |
| 7965 | TSMBuffer bufp; |
| 7966 | TSMLoc hdr; |
| 7967 | TSMLoc field; |
| 7968 | |
| 7969 | if (TSHttpTxnClientReqGet(txnp, &bufp, &hdr) != TS_SUCCESS) { |
| 7970 | SDK_RPRINT(data->test, "TSHttpTxnTransform", "TestCase", TC_FAIL, "TSHttpTxnClientReqGet returns 0"); |
| 7971 | } else { |
| 7972 | if (TS_NULL_MLOC == (field = TSMimeHdrFieldFind(bufp, hdr, "Request", -1))) { |
| 7973 | SDK_RPRINT(data->test, "TSHttpTxnTransform", "TestCase", TC_FAIL, "Didn't find field request"); |
| 7974 | } else { |
| 7975 | int reqid = TSMimeHdrFieldValueIntGet(bufp, hdr, field, 0); |
| 7976 | if (reqid == 1) { |
| 7977 | TSHttpTxnTransformedRespCache(txnp, 0); |
| 7978 | TSHttpTxnUntransformedRespCache(txnp, 1); |
| 7979 | } |
| 7980 | if (reqid == 2) { |
| 7981 | TSHttpTxnTransformedRespCache(txnp, 1); |
| 7982 | TSHttpTxnUntransformedRespCache(txnp, 0); |
| 7983 | } |
| 7984 | if (TSHandleMLocRelease(bufp, hdr, field) != TS_SUCCESS) { |
| 7985 | SDK_RPRINT(data->test, "TSHttpTxnTransform", "TestCase", TC_FAIL, |
| 7986 | "Unable to release handle to field in Client request"); |
| 7987 | } |
| 7988 | } |
| 7989 | if (TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr) != TS_SUCCESS) { |
| 7990 | SDK_RPRINT(data->test, "TSHttpTxnTransform", "TestCase", TC_FAIL, "Unable to release handle to Client request"); |
| 7991 | } |
| 7992 | } |
| 7993 | } |
| 7994 | |
| 7995 | /* Add the transaction hook to SEND_RESPONSE_HDR_HOOK */ |
| 7996 | TSHttpTxnHookAdd(txnp, TS_HTTP_SEND_RESPONSE_HDR_HOOK, contp); |
| 7997 | /* Reenable the transaction */ |
| 7998 | TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE); |
| 7999 | break; |
nothing calls this directly
no test coverage detected