| 4080 | } |
| 4081 | |
| 4082 | TSReturnCode |
| 4083 | TSHttpTxnCachedRespGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *obj) |
| 4084 | { |
| 4085 | sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS); |
| 4086 | sdk_assert(sdk_sanity_check_null_ptr((void *)bufp) == TS_SUCCESS); |
| 4087 | sdk_assert(sdk_sanity_check_null_ptr((void *)obj) == TS_SUCCESS); |
| 4088 | |
| 4089 | HttpSM *sm = reinterpret_cast<HttpSM *>(txnp); |
| 4090 | HTTPInfo *cached_obj = sm->t_state.cache_info.object_read; |
| 4091 | |
| 4092 | // The following check is need to prevent the HttpSM handle copy from going bad |
| 4093 | // Since the cache manages the header buffer, sm->t_state.cache_info.object_read |
| 4094 | // is the only way to tell if handle has gone bad. |
| 4095 | if ((!cached_obj) || (!cached_obj->valid())) { |
| 4096 | return TS_ERROR; |
| 4097 | } |
| 4098 | |
| 4099 | HTTPHdr *cached_hdr = sm->t_state.cache_info.object_read->response_get(); |
| 4100 | |
| 4101 | if (!cached_hdr->valid()) { |
| 4102 | return TS_ERROR; |
| 4103 | } |
| 4104 | // We can't use the HdrHeapSDKHandle structure in the RamCache since multiple |
| 4105 | // threads can access. We need to create our own for the transaction and return that. |
| 4106 | HdrHeapSDKHandle **handle = &(sm->t_state.cache_resp_hdr_heap_handle); |
| 4107 | |
| 4108 | if (*handle == nullptr) { |
| 4109 | *handle = static_cast<HdrHeapSDKHandle *>(sm->t_state.arena.alloc(sizeof(HdrHeapSDKHandle))); |
| 4110 | } |
| 4111 | // Always reset the m_heap to make sure the heap is not stale |
| 4112 | (*handle)->m_heap = cached_hdr->m_heap; |
| 4113 | |
| 4114 | *(reinterpret_cast<HdrHeapSDKHandle **>(bufp)) = *handle; |
| 4115 | *obj = reinterpret_cast<TSMLoc>(cached_hdr->m_http); |
| 4116 | sdk_assert(sdk_sanity_check_mbuffer(*bufp) == TS_SUCCESS); |
| 4117 | |
| 4118 | return TS_SUCCESS; |
| 4119 | } |
| 4120 | |
| 4121 | TSReturnCode |
| 4122 | TSHttpTxnCachedRespModifiableGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *obj) |