HTTP Sessions

An HTTP session is an object that is defined for the lifetime of a client’s TCP session. The Traffic Server API enables you to add a global hook to the start or end of an HTTP session, as well as add session hooks that call back your plugin for every transaction within a given session. When a client connects to Traffic Server, it opens up a TCP connection and sends one or more HTTP requests. An individual request and its response comprise the HTTP transaction. The HTTP session begins when the client opens the connection and ends when the connection closes.

The HTTP session hooks are:

  • TS_HTTP_SSN_START_HOOK Called when an HTTP session is started (a session starts when a client connects to Traffic Server). This hook must be added as a global hook.

  • TS_HTTP_SSN_CLOSE_HOOK Called when an HTTP session ends (a session ends when the client connection is closed). This hook must be added as a global hook. The relative order of invocation between the TS_VCONN_CLOSE_HOOK and TS_HTTP_SSN_CLOSE_HOOK is undefined. In most cases the TS_VCONN_CLOSE_HOOK will execute first, but that is not guaranteed.

Use the session hooks to get a handle to a session (an TSHttpSsn object). If you want your plugin to be called back for each transaction within the session, then use TSHttpSsnHookAdd.

Note: you must re-enable the session with TSHttpSsnReenable after processing a session hook.

The session hook functions are listed below: