Home

Traffic Server Software Developers Kit

Chapter 4. Header-Based Plugin Examples

Table of Contents

Overview
The Blacklist Plugin
Creating the Parent Continuation
Setting a Global Hook
Setting Up UI Update Callbacks
Accessing the Transaction Being Processed
Setting Up a Transaction Hook
Working with HTTP Header Functions
The Basic Authorization Plugin
Creating the Plugin's Parent Continuation and Global Hook
Implementing the Handler and Getting a Handle to the Transaction
Working With HTTP Headers
Setting a Transaction Hook

Header-based plugins read or modify the headers of HTTP messages that Traffic Server sends and receives. Reading this chapter will help you to understand the following topics:

The two sample plugins discussed in this chapter are blacklist-1.c and basic-auth.c.

Overview

Header-based plugins take actions based on the contents of HTTP request or response headers. Examples include filtering (on the basis of requested URL, source IP address, or other request header), user authentication, or user redirection. Header-based plugins have the following common elements:

  • The plugin has a static parent continuation that scans all Traffic Server headers (either request headers, response headers, or both).

  • The plugin has a global hook. This enables the plugin to check all transactions to determine if the plugin needs to do something.

  • The plugin gets a handle to the transaction being processed through the global hook.

  • If the plugin needs to do something to transactions in specific cases, then it sets up a transaction hook for a particular event.

  • The plugin obtains client header information and does something based on that information.

This chapter demonstrates how these components are implemented in SDK sample code.