The State Machine in Detail

Controlling the State Machine

The following TrafficScript functions can be used to control the state machine when processing requests and responses:

Function

Notes

pool.use()

When used in a request rule, aborts all rules processing and specify the pool to give the request to.

request.sendResponse()

http.sendResponse()

When used in a request rule, specifies the response to send to the client. The current request is discarded and no data is sent to any back-end servers.

When the request rules finish, the response rules are run on the provided response.

response.close()

In a response rule, close the connection to the server.

When the response rules complete, pending response data is sent to the client and the Traffic Manager then waits for a new request from the client.

request.endsAt()

request.endsWith()

In a request rule, use these functions to extract individual requests from the incoming data stream and process them synchronously in a request-response manner.

For some protocols, a client might send several requests in one go. These functions can be used to process the requests one-by-one.

request.retry()

In a response rule, retry the request if possible.

All request data that was read before and during a request rule is cached. A request can be retried if all the request data was read and cached; it can't be retried if data was subsequently streamed between the client and the server before a response was received.

response.flush()

In a response rule, flush the current response data. Use response.get() or response.getLine() to read further response data.

This function can be used to manually stream data from the server to the client, ensuring that the response rule does not complete until the response has completed.

connection.close()

connection.discard()

These functions can be used to abort a connection, optionally providing a response. The abort is immediate - no further rules are run at either the request or response stage.