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

Function InjectParentSelectionKeyHeader

plugins/xdebug/xdebug.cc:487–532  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

485}
486
487static void
488InjectParentSelectionKeyHeader(TSHttpTxn txn, TSMBuffer buffer, TSMLoc hdr)
489{
490 TSMLoc url = TS_NULL_MLOC;
491 TSMLoc dst = TS_NULL_MLOC;
492
493 struct {
494 char *ptr;
495 int len;
496 } strval = {nullptr, 0};
497
498 Dbg(dbg_ctl, "attempting to inject X-ParentSelection-Key header");
499
500 if (TSUrlCreate(buffer, &url) != TS_SUCCESS) {
501 goto done;
502 }
503
504 if (TSHttpTxnParentSelectionUrlGet(txn, buffer, url) != TS_SUCCESS) {
505 goto done;
506 }
507
508 strval.ptr = TSUrlStringGet(buffer, url, &strval.len);
509 if (strval.ptr == nullptr || strval.len == 0) {
510 goto done;
511 }
512
513 // Create a new response header field.
514 dst = FindOrMakeHdrField(buffer, hdr, "X-ParentSelection-Key", lengthof("X-ParentSelection-Key"));
515 if (dst == TS_NULL_MLOC) {
516 goto done;
517 }
518
519 // Now copy the parent selection lookup URL into the response header.
520 TSReleaseAssert(TSMimeHdrFieldValueStringInsert(buffer, hdr, dst, -1 /* idx */, strval.ptr, strval.len) == TS_SUCCESS);
521
522done:
523 if (dst != TS_NULL_MLOC) {
524 TSHandleMLocRelease(buffer, hdr, dst);
525 }
526
527 if (url != TS_NULL_MLOC) {
528 TSHandleMLocRelease(buffer, TS_NULL_MLOC, url);
529 }
530
531 TSfree(strval.ptr);
532}
533
534static int
535XInjectResponseHeaders(TSCont /* contp */, TSEvent event, void *edata)

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