Home

Traffic Server Software Developers Kit

Accessing the Transaction Being Processed

A continuation’s handler function is of type INKEventFunc; the prototype is as follows:

static int function_name (INKCont contp, INKEvent event, void *edata)

In general, the return value of the handler function is not used. The continuation argument is the continuation being called back, the event is the event being sent to the continuation, and the data pointed to by void *edata depends on the type of event. The data types for each event type are listed in Writing Handler Functions.

The key here is that if the event is an HTTP transaction event, then the data passed to the continuation’s handler is of type INKHttpTxn (a data type that represents HTTP transactions). Your plugin can then do things with the transaction. Here’s how it looks in the code for the Blacklist plugin’s handler:

static int
blacklist_plugin (INKCont contp, INKEvent event, void *edata)
{
     INKHttpTxn txnp = (INKHttpTxn) edata; 
     switch (event) {
          case INK_EVENT_HTTP_OS_DNS:
               handle_dns (txnp, contp);
               return 0;
          case INK_EVENT_HTTP_SEND_RESPONSE_HDR:
               handle_response (txnp);
               return 0;
          case INK_EVENT_MGMT_UPDATE:
               read_blacklist ();
               return 0;
          default:
               break;
     }
     return 0;
}

For example: when the origin server DNS lookup event is sent, blacklist_plugin can call handle_dns and pass txnp as an argument.