Adds an HTTP session hook.
INKReturnCode INKHttpSsnHookAdd (INKHttpSsn
ssnp
, INKHttpHookID
id
, INKCont
contp
)
Adds
to
the end of the list of HTTP transaction hooks specified by
contp
. This means that
id
is called back
for every transaction within the session, at the point
specified by the hook ID. Since
contp
is added to a
session, it is not possible to call
contp
INKHttpSsnHookAdd
from the plugin
initialization routine. Therefore, the plugin needs a handle to an HTTP
session (see the example below).
#include InkAPI.h static void txn_handler (INKHttpTxn txnp, INKCont contp) { //handle transaction } static void handle_session (INKHttpSsn ssnp, INKCont contp) { INKHttpSsnHookAdd (ssnp, INK_HTTP_TXN_START_HOOK, contp); } static int ssn_handler (INKCont contp, INKEvent event, void *edata) { INKHttpSsn ssnp; INKHttpTxn txnp; switch (event){ case INK_EVENT_HTTP_SSN_START: ssnp = (INKHttpSsn) edata; handle_session (ssnp, contp); INKHttpSsnReenable (ssnp, INK_EVENT_HTTP_CONTINUE); return 0; case INK_EVENT_HTTP_TXN_START: txnp = (INKHttpTxn) edata; txn_handler (txnp, contp); INKHttpTxnReenable (txnp, INK_EVENT_HTTP_CONTINUE); return 0; default: break; } return 0; } void INKPluginInit (int argc, const char *argv[]) { INKCont contp; contp = INKContCreate (ssn_handler, NULL); INKHttpHookAdd (INK_HTTP_SSN_START_HOOK, contp); }
INK_SUCCESS
if the hook is successfully
added.
INK_ERROR
if the hook is not added.
Reenables an HTTP session.
INKReturnCode INKHttpSsnReenable (INKHttpSsn
ssnp
, INKEvent
event
)
Notifies the HTTP session
that the plugin
is done processing the current hook. If
ssnp
INK_EVENT_HTTP_CONTINUE
is specified for
, then the plugin
wants the session to continue. If
event
INK_EVENT_HTTP_ERROR
is specified for
, then the plugin
wants the session to be terminated. An error is then sent
back to the client if no response has already been
sent.event
INK_SUCCESS
if the session is successfully
reenabled.
INK_ERROR
if the hook is not added.