Data Structures | Public Types | Public Member Functions | Friends

atscppapi::Transaction Class Reference

Transactions are the object containing all the state related to a HTTP Transaction. More...

#include <Transaction.h>

Inherits atscppapi::noncopyable.

Collaboration diagram for atscppapi::Transaction:
Collaboration graph
[legend]

Data Structures

class  ContextValue
 ContextValues are a mechanism to share data between plugins using the atscppapi. More...

Public Types

enum  TimeoutType { TIMEOUT_DNS = 0, TIMEOUT_CONNECT, TIMEOUT_NO_ACTIVITY, TIMEOUT_ACTIVE }
 

The available types of timeouts you can set on a Transaction.

More...

Public Member Functions

 ~Transaction ()
shared_ptr< ContextValuegetContextValue (const std::string &key)
 Context Values are a way to share data between plugins, the key is always a string and the value can be a shared_ptr to any type that extends ContextValue.
void setContextValue (const std::string &key, shared_ptr< ContextValue > value)
 Context Values are a way to share data between plugins, the key is always a string and the value can be a shared_ptr to any type that extends ContextValue.
void resume ()
 Causes the Transaction to continue on to other states in the HTTP state machine If you do not call resume() on a Transaction it will remain in that state until it's advanced out by a call to resume() or error().
void error ()
 Causes the Transaction to advance to the error state in the HTTP state machine.
void error (const std::string &content)
 Causes the Transaction to advance to the error state in the HTTP state machine with a specific error message displayed.
void setErrorBody (const std::string &content)
 Sets the error body page but this method does not advance the state machine to the error state.
const sockaddr * getClientAddress () const
 Get the clients address.
const sockaddr * getIncomingAddress () const
 Get the incoming address.
const sockaddr * getServerAddress () const
 Get the server address.
const sockaddr * getNextHopAddress () const
 Get the next hop address.
bool setIncomingPort (uint16_t port)
 Set the incoming port on the Transaction.
bool setServerAddress (const sockaddr *)
 Sets the server address on the Transaction to a populated sockaddr *.
bool isInternalRequest () const
 Returns a boolean value if the request is an internal request.
ClientRequestgetClientRequest ()
 Returns the ClientRequest object for the incoming request from the client.
RequestgetServerRequest ()
 Returns a Request object which is the request from Traffic Server to the origin server.
ResponsegetServerResponse ()
 Returns a Response object which is the response coming from the origin server.
ResponsegetClientResponse ()
 Returns a Response object which is the response going to the client.
std::string getEffectiveUrl ()
 Returns the Effective URL for this transaction taking into account host.
bool setCacheUrl (const std::string &)
 Sets the url used by the ATS cache for a specific transaction.
void setTimeout (TimeoutType type, int time_ms)
 Allows you to set various types of timeouts on a Transaction.
void * getAtsHandle () const
 Returns the TSHttpTxn related to the current Transaction.
void addPlugin (TransactionPlugin *)
 Adds a TransactionPlugin to the current Transaction.
size_t getServerResponseBodySize ()
 Get the number of bytes for the response body as returned by the server.
size_t getServerResponseHeaderSize ()
 Get the nubmber of bytes for the response headers as returned by the server.
size_t getClientResponseBodySize ()
 Get the number of bytes for the client response.
size_t getClientResponseHeaderSize ()
 Get the number of bytes for the response headers.

Friends

class TransactionPlugin
 TransactionPlugin is a friend so it can call addPlugin().
class TransformationPlugin
 TransformationPlugin is a friend so it can call addPlugin().
class utils::internal

Detailed Description

Transactions are the object containing all the state related to a HTTP Transaction.

Warning:
Transactions should never be directly created by the user, they will always be automatically created and destroyed as they are needed. Transactions should never be saved beyond the scope of the function in which they are delivered otherwise undefined behaviour will result.

Definition at line 48 of file Transaction.h.


Member Enumeration Documentation

The available types of timeouts you can set on a Transaction.

Enumerator:
TIMEOUT_DNS 

Timeout on DNS.

TIMEOUT_CONNECT 

Timeout on Connect.

TIMEOUT_NO_ACTIVITY 

Timeout on No Activity.

TIMEOUT_ACTIVE 

Timeout with Activity.

Definition at line 236 of file Transaction.h.


Constructor & Destructor Documentation

atscppapi::Transaction::~Transaction (  ) 

Member Function Documentation

void atscppapi::Transaction::addPlugin ( TransactionPlugin  ) 

Adds a TransactionPlugin to the current Transaction.

This effectively transfers ownership and the Transaction is now responsible for cleaning it up.

Parameters:
TransactionPlugin* the TransactionPlugin that will be now bound to the current Transaction.
void atscppapi::Transaction::error (  ) 

Causes the Transaction to advance to the error state in the HTTP state machine.

See also:
error(const std::string &)
void atscppapi::Transaction::error ( const std::string &  content  ) 

Causes the Transaction to advance to the error state in the HTTP state machine with a specific error message displayed.

This is functionally equivalent to the following:

Parameters:
content the error page body.
void* atscppapi::Transaction::getAtsHandle (  )  const

Returns the TSHttpTxn related to the current Transaction.

Returns:
a void * which can be cast back to a TSHttpTxn.
const sockaddr* atscppapi::Transaction::getClientAddress (  )  const

Get the clients address.

Returns:
The sockaddr structure representing the client's address
See also:
atscppapi::utils::getIpString() in atscppapi/utils.h
atscppapi::utils::getPort() in atscppapi/utils.h
atscppapi::utils::getIpPortString in atscppapi/utils.h
ClientRequest& atscppapi::Transaction::getClientRequest (  ) 

Returns the ClientRequest object for the incoming request from the client.

Returns:
ClientRequest object that can be used to manipulate the incoming request from the client.
Response& atscppapi::Transaction::getClientResponse (  ) 

Returns a Response object which is the response going to the client.

Returns:
Response object that can be used to manipulate the outgoing response from the client.
size_t atscppapi::Transaction::getClientResponseBodySize (  ) 

Get the number of bytes for the client response.

This can differ from the server response size because of transformations.

Returns:
client response body size
size_t atscppapi::Transaction::getClientResponseHeaderSize (  ) 

Get the number of bytes for the response headers.

This can differ from the server response because headers can be modified.

Returns:
client response header size
shared_ptr<ContextValue> atscppapi::Transaction::getContextValue ( const std::string &  key  ) 

Context Values are a way to share data between plugins, the key is always a string and the value can be a shared_ptr to any type that extends ContextValue.

Parameters:
key the key to search for.
Returns:
Shared pointer that is correctly initialized if the value existed. It should be checked with .get() != NULL before use.
std::string atscppapi::Transaction::getEffectiveUrl (  ) 

Returns the Effective URL for this transaction taking into account host.

const sockaddr* atscppapi::Transaction::getIncomingAddress (  )  const

Get the incoming address.

Returns:
The sockaddr structure representing the incoming address
See also:
atscppapi::utils::getIpString() in atscppapi/utils.h
atscppapi::utils::getPort() in atscppapi/utils.h
atscppapi::utils::getIpPortString in atscppapi/utils.h
const sockaddr* atscppapi::Transaction::getNextHopAddress (  )  const

Get the next hop address.

Returns:
The sockaddr structure representing the next hop's address
See also:
atscppapi::utils::getIpString() in atscppapi/utils.h
atscppapi::utils::getPort() in atscppapi/utils.h
atscppapi::utils::getIpPortString in atscppapi/utils.h
const sockaddr* atscppapi::Transaction::getServerAddress (  )  const

Get the server address.

Returns:
The sockaddr structure representing the server's address
See also:
atscppapi::utils::getIpString() in atscppapi/utils.h
atscppapi::utils::getPort() in atscppapi/utils.h
atscppapi::utils::getIpPortString in atscppapi/utils.h
Request& atscppapi::Transaction::getServerRequest (  ) 

Returns a Request object which is the request from Traffic Server to the origin server.

Returns:
Request object that can be used to manipulate the outgoing request to the origin server.
Response& atscppapi::Transaction::getServerResponse (  ) 

Returns a Response object which is the response coming from the origin server.

Returns:
Response object that can be used to manipulate the incoming response from the origin server.
size_t atscppapi::Transaction::getServerResponseBodySize (  ) 

Get the number of bytes for the response body as returned by the server.

Returns:
server response body size
size_t atscppapi::Transaction::getServerResponseHeaderSize (  ) 

Get the nubmber of bytes for the response headers as returned by the server.

Returns:
server response header size
bool atscppapi::Transaction::isInternalRequest (  )  const

Returns a boolean value if the request is an internal request.

A request is an internal request if it originates from within traffic server. An example would be using TSFetchUrl (or the atscppapi equivalent of AsyncHttpFetch) to make another request along with the original request. The secondary request originated within traffic server and is an internal request.

Returns:
boolean value specifying if the request was an internal request.
void atscppapi::Transaction::resume (  ) 
bool atscppapi::Transaction::setCacheUrl ( const std::string &   ) 

Sets the url used by the ATS cache for a specific transaction.

Parameters:
url is the url to use in the cache.
void atscppapi::Transaction::setContextValue ( const std::string &  key,
shared_ptr< ContextValue value 
)

Context Values are a way to share data between plugins, the key is always a string and the value can be a shared_ptr to any type that extends ContextValue.

Parameters:
key the key to insert.
value a shared pointer to a class that extends ContextValue.
void atscppapi::Transaction::setErrorBody ( const std::string &  content  ) 

Sets the error body page but this method does not advance the state machine to the error state.

To do that you must explicitally call error().

Parameters:
content the error page content.
bool atscppapi::Transaction::setIncomingPort ( uint16_t  port  ) 

Set the incoming port on the Transaction.

Parameters:
port is the port to set as the incoming port on the transaction
bool atscppapi::Transaction::setServerAddress ( const sockaddr *   ) 

Sets the server address on the Transaction to a populated sockaddr *.

Parameters:
sockaddr* the sockaddr structure populated as the server address.
void atscppapi::Transaction::setTimeout ( TimeoutType  type,
int  time_ms 
)

Allows you to set various types of timeouts on a Transaction.

Parameters:
type The type of timeout
time_ms The timeout time in milliseconds
See also:
TimeoutType

Friends And Related Function Documentation

friend class TransactionPlugin [friend]

TransactionPlugin is a friend so it can call addPlugin().

Definition at line 303 of file Transaction.h.

friend class TransformationPlugin [friend]

TransformationPlugin is a friend so it can call addPlugin().

Definition at line 304 of file Transaction.h.

friend class utils::internal [friend]

Definition at line 343 of file Transaction.h.


The documentation for this class was generated from the following file: