MCPcopy Create free account
hub / github.com/apache/trafficserver / TSHttpTxnIsCacheable

Function TSHttpTxnIsCacheable

src/api/InkAPI.cc:7839–7863  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7837}
7838
7839int
7840TSHttpTxnIsCacheable(TSHttpTxn txnp, TSMBuffer request, TSMBuffer response)
7841{
7842 sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
7843 HttpSM *sm = reinterpret_cast<HttpSM *>(txnp);
7844 HTTPHdr *req, *resp;
7845
7846 // We allow for either request or response to be empty (or both), in
7847 // which case we default to the transactions request or response.
7848 if (request) {
7849 sdk_assert(sdk_sanity_check_mbuffer(request) == TS_SUCCESS);
7850 req = reinterpret_cast<HTTPHdr *>(request);
7851 } else {
7852 req = &(sm->t_state.hdr_info.client_request);
7853 }
7854 if (response) {
7855 sdk_assert(sdk_sanity_check_mbuffer(response) == TS_SUCCESS);
7856 resp = reinterpret_cast<HTTPHdr *>(response);
7857 } else {
7858 resp = &(sm->t_state.hdr_info.server_response);
7859 }
7860
7861 // Make sure these are valid response / requests, then verify if it's cacheable.
7862 return (req->valid() && resp->valid() && HttpTransact::is_response_cacheable(&(sm->t_state), req, resp)) ? 1 : 0;
7863}
7864
7865int
7866TSHttpTxnGetMaxAge(TSHttpTxn txnp, TSMBuffer response)

Callers 3

cont_check_cacheableFunction · 0.85

Calls 3

sdk_sanity_check_txnFunction · 0.85
sdk_sanity_check_mbufferFunction · 0.85
validMethod · 0.45

Tested by

no test coverage detected