two hooks this function may gets called: TS_HTTP_READ_CACHE_HDR_HOOK & TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK */
| 4200 | TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK |
| 4201 | */ |
| 4202 | TSReturnCode |
| 4203 | TSHttpTxnCacheLookupStatusSet(TSHttpTxn txnp, int cachelookup) |
| 4204 | { |
| 4205 | sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS); |
| 4206 | |
| 4207 | HttpSM *sm = reinterpret_cast<HttpSM *>(txnp); |
| 4208 | HttpTransact::CacheLookupResult_t *sm_status = &(sm->t_state.cache_lookup_result); |
| 4209 | |
| 4210 | // converting from a miss to a hit is not allowed |
| 4211 | if (*sm_status == HttpTransact::CACHE_LOOKUP_MISS && cachelookup != TS_CACHE_LOOKUP_MISS) { |
| 4212 | return TS_ERROR; |
| 4213 | } |
| 4214 | |
| 4215 | // here is to handle converting a hit to a miss |
| 4216 | if (cachelookup == TS_CACHE_LOOKUP_MISS && *sm_status != HttpTransact::CACHE_LOOKUP_MISS) { |
| 4217 | sm->t_state.api_cleanup_cache_read = true; |
| 4218 | ink_assert(sm->t_state.transact_return_point != nullptr); |
| 4219 | sm->t_state.transact_return_point = HttpTransact::HandleCacheOpenRead; |
| 4220 | } |
| 4221 | |
| 4222 | switch (cachelookup) { |
| 4223 | case TS_CACHE_LOOKUP_MISS: |
| 4224 | *sm_status = HttpTransact::CACHE_LOOKUP_MISS; |
| 4225 | break; |
| 4226 | case TS_CACHE_LOOKUP_HIT_STALE: |
| 4227 | *sm_status = HttpTransact::CACHE_LOOKUP_HIT_STALE; |
| 4228 | break; |
| 4229 | case TS_CACHE_LOOKUP_HIT_FRESH: |
| 4230 | *sm_status = HttpTransact::CACHE_LOOKUP_HIT_FRESH; |
| 4231 | break; |
| 4232 | default: |
| 4233 | return TS_ERROR; |
| 4234 | } |
| 4235 | |
| 4236 | return TS_SUCCESS; |
| 4237 | } |
| 4238 | |
| 4239 | TSReturnCode |
| 4240 | TSHttpTxnInfoIntGet(TSHttpTxn txnp, TSHttpTxnInfoKey key, TSMgmtInt *value) |
no test coverage detected