Transactions are the object containing all the state related to a HTTP Transaction. More...
#include <Transaction.h>
Inherits atscppapi::noncopyable.
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< ContextValue > | 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. | |
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. | |
ClientRequest & | getClientRequest () |
Returns the ClientRequest object for the incoming request from the client. | |
Request & | getServerRequest () |
Returns a Request object which is the request from Traffic Server to the origin server. | |
Response & | getServerResponse () |
Returns a Response object which is the response coming from the origin server. | |
Response & | getClientResponse () |
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 |
Transactions are the object containing all the state related to a HTTP Transaction.
Definition at line 48 of file Transaction.h.
The available types of timeouts you can set on a Transaction.
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.
atscppapi::Transaction::~Transaction | ( | ) |
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.
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.
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:
setErrorBody(content); error();
content | the error page body. |
void* atscppapi::Transaction::getAtsHandle | ( | ) | const |
Returns the TSHttpTxn related to the current Transaction.
const sockaddr* atscppapi::Transaction::getClientAddress | ( | ) | const |
Get the clients address.
ClientRequest& atscppapi::Transaction::getClientRequest | ( | ) |
Returns the ClientRequest object for the incoming request from the client.
Response& atscppapi::Transaction::getClientResponse | ( | ) |
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.
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.
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.
key | the key to search for. |
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.
const sockaddr* atscppapi::Transaction::getNextHopAddress | ( | ) | const |
Get the next hop address.
const sockaddr* atscppapi::Transaction::getServerAddress | ( | ) | const |
Get the server address.
Request& atscppapi::Transaction::getServerRequest | ( | ) |
Response& atscppapi::Transaction::getServerResponse | ( | ) |
size_t atscppapi::Transaction::getServerResponseBodySize | ( | ) |
Get the number of bytes for the response body as returned by the server.
size_t atscppapi::Transaction::getServerResponseHeaderSize | ( | ) |
Get the nubmber of bytes for the response headers as returned by the server.
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.
void atscppapi::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().
Referenced by atscppapi::Plugin::handleOsDns(), atscppapi::Plugin::handleReadRequestHeadersPostRemap(), atscppapi::Plugin::handleReadRequestHeadersPreRemap(), atscppapi::Plugin::handleReadResponseHeaders(), atscppapi::Plugin::handleSendRequestHeaders(), and atscppapi::Plugin::handleSendResponseHeaders().
bool atscppapi::Transaction::setCacheUrl | ( | const std::string & | ) |
Sets the url used by the ATS cache for a specific transaction.
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.
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().
content | the error page content. |
bool atscppapi::Transaction::setIncomingPort | ( | uint16_t | port | ) |
Set the incoming port on the Transaction.
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 *.
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.
type | The type of timeout | |
time_ms | The timeout time in milliseconds |
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.