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

Function InjectCacheInfoHeader

plugins/xdebug/xdebug.cc:222–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220}
221
222static void
223InjectCacheInfoHeader(TSHttpTxn txn, TSMBuffer buffer, TSMLoc hdr)
224{
225 TSMLoc dst = TS_NULL_MLOC;
226 TSMgmtInt volume;
227 const char *path;
228
229 Dbg(dbg_ctl, "attempting to inject X-Cache-Info header");
230
231 if ((path = TSHttpTxnCacheDiskPathGet(txn, nullptr)) == nullptr) {
232 goto done;
233 }
234
235 if (TSHttpTxnInfoIntGet(txn, TS_TXN_INFO_CACHE_VOLUME, &volume) != TS_SUCCESS) {
236 goto done;
237 }
238
239 // Create a new response header field.
240 dst = FindOrMakeHdrField(buffer, hdr, "X-Cache-Info", lengthof("X-Cache-Info"));
241 if (dst == TS_NULL_MLOC) {
242 goto done;
243 }
244
245 char value[1024];
246 snprintf(value, sizeof(value), "path=%s; volume=%" PRId64, path, volume);
247
248 // Now copy the CacheDisk info into the response header.
249 TSReleaseAssert(TSMimeHdrFieldValueStringInsert(buffer, hdr, dst, -1 /* idx */, value, std::strlen(value)) == TS_SUCCESS);
250
251done:
252 if (dst != TS_NULL_MLOC) {
253 TSHandleMLocRelease(buffer, hdr, dst);
254 }
255}
256
257static void
258InjectCacheHeader(TSHttpTxn txn, TSMBuffer buffer, TSMLoc hdr)

Callers 1

XInjectResponseHeadersFunction · 0.85

Calls 6

TSHttpTxnInfoIntGetFunction · 0.85
FindOrMakeHdrFieldFunction · 0.85
TSHandleMLocReleaseFunction · 0.85
lengthofFunction · 0.70

Tested by

no test coverage detected