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

Method getPathHash

src/proxy/ParentConsistentHash.cc:70–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70uint64_t
71ParentConsistentHash::getPathHash(HttpRequestData *hrdata, ATSHash64 *h)
72{
73 const char *url_string_ref = nullptr;
74 int len;
75 URL *ps_url = nullptr;
76
77 // Use over-ride URL from HttpTransact::State's cache_info.parent_selection_url, if present.
78 if (hrdata->cache_info_parent_selection_url) {
79 ps_url = *(hrdata->cache_info_parent_selection_url);
80 if (ps_url) {
81 url_string_ref = ps_url->string_get_ref(&len);
82 if (url_string_ref && len > 0) {
83 // Print the over-ride URL
84 Dbg(dbg_ctl_parent_select, "Using Over-Ride String='%.*s'.", len, url_string_ref);
85 h->update(url_string_ref, len);
86 h->final();
87 return h->get();
88 }
89 }
90 }
91
92 ps_url = hrdata->hdr->url_get();
93
94 // Always hash on '/' because paths returned by ATS are always stripped of it
95 h->update("/", 1);
96
97 url_string_ref = ps_url->path_get(&len);
98 if (url_string_ref) {
99 h->update(url_string_ref, len);
100 }
101
102 if (!ignore_query) {
103 url_string_ref = ps_url->query_get(&len);
104 if (url_string_ref) {
105 h->update("?", 1);
106 h->update(url_string_ref, len);
107 }
108 }
109
110 h->final();
111
112 return h->get();
113}
114
115// Helper function to abstract calling ATSConsistentHash lookup_by_hashval() vs lookup().
116static pRecord *

Callers

nothing calls this directly

Calls 7

string_get_refMethod · 0.80
url_getMethod · 0.80
updateMethod · 0.45
finalMethod · 0.45
getMethod · 0.45
path_getMethod · 0.45
query_getMethod · 0.45

Tested by

no test coverage detected