static int handle_txn_start(INKCont contp, INKHttpTxn txnp) { LOG_SET_FUNCTION_NAME("handle_txn_start"); if (INKHttpTxnHookAdd(txnp, INK_HTTP_READ_CACHE_HDR_HOOK, contp) == INK_ERROR) LOG_ERROR_AND_RETURN("INKHttpTxnHookAdd"); if (INKHttpTxnHookAdd(txnp, INK_HTTP_READ_RESPONSE_HDR_HOOK, contp) == INK_ERROR) LOG_ERROR_AND_RETURN("INKHttpTxnHookAdd"); return 0; }
static void handleTxnStart(INKCont pCont, INKHttpTxn pTxn) { LOG_SET_FUNCTION_NAME("handleTxnStart"); if (INKHttpTxnHookAdd(pTxn, INK_HTTP_READ_REQUEST_HDR_HOOK, pCont) == INK_ERROR) { LOG_API_ERROR("INKHttpHookAdd"); } if (INKHttpTxnHookAdd(pTxn, INK_HTTP_SEND_RESPONSE_HDR_HOOK, pCont) == INK_ERROR) { LOG_API_ERROR("INKHttpHookAdd"); } if (INKHttpTxnReenable(pTxn, INK_EVENT_HTTP_CONTINUE) == INK_ERROR) { LOG_API_ERROR("INKHttpTxnReenable"); } }
static int event_mux(INKCont contp, INKEvent event, void *edata) { INKHttpTxn txnp = (INKHttpTxn) edata; INKCont newcont; char *client_req; char *url_line; int ret_status; int neg_test_val; int pin_val; LOG_SET_FUNCTION_NAME("event_mux"); switch (event) { case INK_EVENT_HTTP_SEND_RESPONSE_HDR: if ((newcont = INKContCreate(handle_cache_events, INKMutexCreate())) == INK_ERROR_PTR) { LOG_ERROR_AND_REENABLE("INKContCreate"); return 0; } /* FC When called back for txn close, the plugins test if the value of the continuation data ptr is null or not. Initialize it here to null. */ INKContDataSet(newcont, NULL); if (INKHttpTxnHookAdd(edata, INK_HTTP_TXN_CLOSE_HOOK, newcont) == INK_ERROR) { LOG_ERROR_AND_REENABLE("INKHttpTxnHookAdd"); return 0; } ret_status = get_client_req(txnp, &url_line, &client_req, &neg_test_val, &pin_val); /* FC: added test on url and client req too */ if ((ret_status == -1) || (url_line == NULL) || (client_req == NULL)) { INKDebug(DEBUG_TAG, "Unable to get client request header\n"); INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE); return 0; } INKDebug(DEBUG_TAG, "\n%s\n%s", url_line, client_req); INKfree(client_req); cache_exercise(txnp, url_line, pin_val, neg_test_val, newcont); break; default: ; } return 0; }
static int attach_test(INKCont contp, INKEvent event, void *edata) { INKHttpTxn txnp = (INKHttpTxn) edata; INKCont new_cont; switch (event) { case INK_EVENT_HTTP_READ_REQUEST_HDR: new_cont = INKContCreate(test_destroy_plugin, INKMutexCreate()); INKHttpTxnHookAdd(txnp, INK_HTTP_TXN_CLOSE_HOOK, new_cont); INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE); break; default: INKAssert(0); } return 0; }