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

Function TSHttpTxnCachedRespGet

src/api/InkAPI.cc:4082–4119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4080}
4081
4082TSReturnCode
4083TSHttpTxnCachedRespGet(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
4121TSReturnCode
4122TSHttpTxnCachedRespModifiableGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *obj)

Callers 11

modify_headerFunction · 0.85
cache_hook_handlerFunction · 0.85
getServerStateMethod · 0.85
isTxnTransformableFunction · 0.85
is_content_compressibleFunction · 0.85
get_date_from_cached_hdrFunction · 0.85
get_date_from_cached_hdrFunction · 0.85
get_cached_header_infoFunction · 0.85

Calls 6

sdk_sanity_check_txnFunction · 0.85
sdk_sanity_check_mbufferFunction · 0.85
response_getMethod · 0.80
validMethod · 0.45
allocMethod · 0.45

Tested by 1

cache_hook_handlerFunction · 0.68