TSHttpTxnServerIntercept

Intercept origin server requests.

Synopsis

#include <ts/ts.h>

void TSHttpTxnServerIntercept(TSCont contp, TSHttpTxn txnp)

Description

TSHttpTxnServerIntercept() allows a plugin take over the servicing of the request as though it was the origin server. In the event a request needs to be made to the server for transaction txnp, contp will be sent a TS_EVENT_NET_ACCEPT event. The edata passed with TS_EVENT_NET_ACCEPT is an TSVConn just as it would be for a normal accept. The plugin must act as if it is an HTTP server and read the HTTP request and body from the TSVConn and send an HTTP response header and body.

TSHttpTxnServerIntercept() must be not be called after the connection to the server has taken place. This means that the last hook that it can be called from is TS_HTTP_READ_CACHE_HDR_HOOK. If a connection to the server is not necessary, the continuation contp will be sent a TS_EVENT_NET_ACCEPT_FAILED event when the transaction completes.

The response from the plugin is cached subject to standard and configured HTTP caching rules. Should the plugin wish the response not be cached, the plugin must use appropriate HTTP response headers to prevent caching. The primary purpose of TSHttpTxnServerIntercept() is allow plugins to provide gateways to other protocols or to allow to plugin to its own transport for the next hop to the server. TSHttpTxnServerIntercept() overrides parent cache configuration.

TSHttpTxnServerIntercept() must only be called once per transaction. The continuation contp must have been created with a valid TSMutex.

See Also

TSAPI(3ts)