Hooks and Transactions¶
Hooks are points in Traffic Server transaction processing where plugins can step in and do some work. Registering a plugin function for callback amounts to “adding” the function to a hook. You can register your plugin to be called back for every single transaction or only for specific transactions.
This chapter contains the following sections:
- Adding Hooks
- HTTP Sessions
- HTTP Transactions
- Intercepting HTTP Transactions
- Initiate HTTP Connection
- HTTP Alternate Selection
- TLS User Agent Hooks
- TLS Session Plugin API
- Utility Functions
- Example Use Case
To understand hooks and transactions, you should be familiar with the following terminology:
A transaction consists of a single HTTP request from a client and the response Traffic Server sends to that client. Thus, a transaction begins when Traffic Server receives a request and ends when Traffic Server sends the response.
Traffic Server uses HTTP state machines to process transactions. The state machines follow a complex set of states involved in sophisticated caching and document retrieval (taking into account, for example, alternate selection, freshness criteria, and hierarchical caching). The Traffic Server API provides hooks to a subset of these states, as illustrated in the HTTP Transaction State Diagram below.
The two transform hooks,
TS_HTTP_RESPONSE_TRANSFORM_HOOK, are called in the course of an HTTP
transform. To see where in the HTTP transaction they are called, look
for the “set up transform” ovals in the HTTP Transaction State Diagram below.
A session consists of a single client connection to Traffic Server; it may consist of a single transaction or several transactions in succession. The session starts when the client connection opens and ends when the connection closes.
HTTP Transaction State Diagram¶
HTTP Transacation Timers¶
For an overview of HTTP transaction timers, refer to the transaction timer diagram below.