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

Method appendHeaders

plugins/cachekey/cachekey.cc:545–578  ·  view source on GitHub ↗

* @brief Append headers by following the rules specified in the header configuration object. * @param config header-related configuration containing information about which headers need to be appended to the key. * @note Add the headers to hier-part (RFC 3986), always sort them in the cache key. */

Source from the content-addressed store, hash-verified

543 * @note Add the headers to hier-part (RFC 3986), always sort them in the cache key.
544 */
545void
546CacheKey::appendHeaders(const ConfigHeaders &config)
547{
548 if (!config.toBeRemoved() && !config.toBeSkipped()) {
549 /* Iterating header by header is not efficient according to comments inside traffic server API,
550 * Iterate over an 'include'-kind of list or the capture definitions to avoid header by header iteration.
551 * @todo: revisit this when (if?) adding regex matching for headers. */
552
553 /* Adding whole headers, iterate over "--include-header" list */
554 StringSet hdrSet; /* Sort and uniquify the header list in the cache key. */
555 for (auto it = config.getInclude().begin(); it != config.getInclude().end(); ++it) {
556 processHeader(*it, config, hdrSet, captureWholeHeaders);
557 }
558
559 /* Append to the cache key. It doesn't make sense to have the headers unordered in the cache key. */
560 String headers_key = containerToString<StringSet, StringSet::const_iterator>(hdrSet, "", _separator);
561 if (!headers_key.empty()) {
562 append(headers_key);
563 }
564 }
565
566 if (!config.getCaptures().empty()) {
567 /* Adding captures from headers, iterate over "--capture-header" definitions */
568 StringVector hdrCaptures;
569 for (auto it = config.getCaptures().begin(); it != config.getCaptures().end(); ++it) {
570 processHeader(it->first, config, hdrCaptures, captureFromHeaders);
571 }
572
573 /* Append to the cache key. Add the captures in the order capture definitions are captured / specified */
574 for (auto &capture : hdrCaptures) {
575 append(capture);
576 }
577 }
578}
579
580/**
581 * @brief Append cookies by following the rules specified in the cookies config object.

Callers 1

setCacheKeyFunction · 0.80

Calls 6

toBeRemovedMethod · 0.80
toBeSkippedMethod · 0.80
appendFunction · 0.70
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected