atscppapi  1.0.9
C++ wrapper for Apache Traffic Server API
 All Classes Files Functions Enumerations Enumerator Macros
Classes | Public Types | Public Member Functions | List of all members
atscppapi::Transaction Class Reference

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

#include "Transaction.h"

Inherits atscppapi::noncopyable.

Classes

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 }
 

Public Member Functions

shared_ptr< ContextValuegetContextValue (const std::string &key)
 
void setContextValue (const std::string &key, shared_ptr< ContextValue > value)
 
void resume ()
 
void error ()
 
void error (const std::string &content)
 
void setErrorBody (const std::string &content)
 
const sockaddr * getClientAddress () const
 
const sockaddr * getIncomingAddress () const
 
const sockaddr * getServerAddress () const
 
const sockaddr * getNextHopAddress () const
 
bool setIncomingPort (uint16_t port)
 
bool setServerAddress (const sockaddr *)
 
bool isInternalRequest () const
 
ClientRequestgetClientRequest ()
 
RequestgetServerRequest ()
 
ResponsegetServerResponse ()
 
ResponsegetClientResponse ()
 
std::string getEffectiveUrl ()
 
bool setCacheUrl (const std::string &)
 
void setTimeout (TimeoutType type, int time_ms)
 
void * getAtsHandle () const
 
void addPlugin (TransactionPlugin *)
 

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.

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

Member Function Documentation

void Transaction::addPlugin ( TransactionPlugin plugin)

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 Transaction::error ( )

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

See Also
error(const std::string &)
void 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:

setErrorBody(content);
Parameters
contentthe error page body.
void * Transaction::getAtsHandle ( ) const

Returns the TSHttpTxn related to the current Transaction

Returns
a void * which can be cast back to a TSHttpTxn.
const sockaddr * 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 & 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 & 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.
shared_ptr< Transaction::ContextValue > 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
keythe key to search for.
Returns
Shared pointer that is correctly initialized if the value existed. It should be checked with .get() != NULL before use.
string Transaction::getEffectiveUrl ( )

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

const sockaddr * 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 * 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 * 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 & 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 & 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.
bool 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 Transaction::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().

bool Transaction::setCacheUrl ( const std::string &  )

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

Parameters
urlis the url to use in the cache.
void 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
keythe key to insert.
valuea shared pointer to a class that extends ContextValue.
void 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
contentthe error page content.
bool Transaction::setIncomingPort ( uint16_t  port)

Set the incoming port on the Transaction

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

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

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

Allows you to set various types of timeouts on a Transaction

Parameters
typeThe type of timeout
time_msThe timeout time in milliseconds
See Also
TimeoutType

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