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

Function InjectCacheKeyHeader

plugins/xdebug/xdebug.cc:175–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175static void
176InjectCacheKeyHeader(TSHttpTxn txn, TSMBuffer buffer, TSMLoc hdr)
177{
178 TSMLoc url = TS_NULL_MLOC;
179 TSMLoc dst = TS_NULL_MLOC;
180
181 struct {
182 char *ptr;
183 int len;
184 } strval = {nullptr, 0};
185
186 Dbg(dbg_ctl, "attempting to inject X-Cache-Key header");
187
188 if (TSUrlCreate(buffer, &url) != TS_SUCCESS) {
189 goto done;
190 }
191
192 if (TSHttpTxnCacheLookupUrlGet(txn, buffer, url) != TS_SUCCESS) {
193 goto done;
194 }
195
196 strval.ptr = TSUrlStringGet(buffer, url, &strval.len);
197 if (strval.ptr == nullptr || strval.len == 0) {
198 goto done;
199 }
200
201 // Create a new response header field.
202 dst = FindOrMakeHdrField(buffer, hdr, "X-Cache-Key", lengthof("X-Cache-Key"));
203 if (dst == TS_NULL_MLOC) {
204 goto done;
205 }
206
207 // Now copy the cache lookup URL into the response header.
208 TSReleaseAssert(TSMimeHdrFieldValueStringInsert(buffer, hdr, dst, -1 /* idx */, strval.ptr, strval.len) == TS_SUCCESS);
209
210done:
211 if (dst != TS_NULL_MLOC) {
212 TSHandleMLocRelease(buffer, hdr, dst);
213 }
214
215 if (url != TS_NULL_MLOC) {
216 TSHandleMLocRelease(buffer, TS_NULL_MLOC, url);
217 }
218
219 TSfree(strval.ptr);
220}
221
222static void
223InjectCacheInfoHeader(TSHttpTxn txn, TSMBuffer buffer, TSMLoc hdr)

Callers 1

XInjectResponseHeadersFunction · 0.85

Calls 8

TSUrlCreateFunction · 0.85
TSUrlStringGetFunction · 0.85
FindOrMakeHdrFieldFunction · 0.85
TSHandleMLocReleaseFunction · 0.85
TSfreeFunction · 0.85
lengthofFunction · 0.70

Tested by

no test coverage detected