| 220 | } |
| 221 | |
| 222 | static void |
| 223 | InjectCacheInfoHeader(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 | |
| 251 | done: |
| 252 | if (dst != TS_NULL_MLOC) { |
| 253 | TSHandleMLocRelease(buffer, hdr, dst); |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | static void |
| 258 | InjectCacheHeader(TSHttpTxn txn, TSMBuffer buffer, TSMLoc hdr) |
no test coverage detected