| 1455 | } |
| 1456 | |
| 1457 | static bool |
| 1458 | addTransform(TSHttpTxn txnp, const bool processing_os_response, const bool intercept_header, const bool head_only, |
| 1459 | const OptionInfo *pOptionInfo) |
| 1460 | { |
| 1461 | TSCont contp = nullptr; |
| 1462 | ContData *cont_data = nullptr; |
| 1463 | |
| 1464 | contp = TSTransformCreate(transformHandler, txnp); |
| 1465 | if (!contp) { |
| 1466 | TSError("[esi][%s] Error while creating a new transformation", __FUNCTION__); |
| 1467 | goto lFail; |
| 1468 | } |
| 1469 | |
| 1470 | cont_data = new ContData(contp, txnp, pOptionInfo); |
| 1471 | TSContDataSet(contp, cont_data); |
| 1472 | |
| 1473 | cont_data->cache_txn = !processing_os_response; |
| 1474 | cont_data->intercept_header = intercept_header; |
| 1475 | cont_data->head_only = head_only; |
| 1476 | cont_data->getClientState(); |
| 1477 | cont_data->getServerState(); |
| 1478 | |
| 1479 | if (cont_data->cache_txn) { |
| 1480 | if (cont_data->option_info->packed_node_support) { |
| 1481 | if (cont_data->input_type != DATA_TYPE_PACKED_ESI) { |
| 1482 | removeCacheKey(txnp); |
| 1483 | } |
| 1484 | } else { |
| 1485 | if (cont_data->input_type == DATA_TYPE_PACKED_ESI) { |
| 1486 | removeCacheKey(txnp); |
| 1487 | } |
| 1488 | } |
| 1489 | } |
| 1490 | |
| 1491 | TSHttpTxnHookAdd(txnp, TS_HTTP_RESPONSE_TRANSFORM_HOOK, contp); |
| 1492 | |
| 1493 | if (!addSendResponseHeaderHook(txnp, cont_data)) { |
| 1494 | TSError("[esi][%s] Couldn't add send response header hook", __FUNCTION__); |
| 1495 | goto lFail; |
| 1496 | } |
| 1497 | |
| 1498 | TSHttpTxnTransformedRespCache(txnp, 0); |
| 1499 | if (cont_data->option_info->packed_node_support) { |
| 1500 | TSHttpTxnUntransformedRespCache(txnp, 0); |
| 1501 | } else { |
| 1502 | TSHttpTxnUntransformedRespCache(txnp, 1); |
| 1503 | } |
| 1504 | |
| 1505 | Dbg(dbg_ctl_local, "[%s] Added transformation (0x%p)", __FUNCTION__, contp); |
| 1506 | return true; |
| 1507 | |
| 1508 | lFail: |
| 1509 | if (contp) { |
| 1510 | TSContDestroy(contp); |
| 1511 | } |
| 1512 | if (cont_data) { |
| 1513 | delete cont_data; |
| 1514 | } |
no test coverage detected