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

Function do_remap

example/cripts/example2.cc:118–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118do_remap()
119{
120 auto ip = client.connection.IP();
121 auto now = TimeNow();
122
123 if (CRIPT_ALLOW.Match(ip)) {
124 CDebug("Client IP allowed: {}", ip.string(24, 64));
125 }
126
127 CDebug("Epoch time is {} (or via .epoch(), {}", now, now.Epoch());
128 CDebug("Year is {}", now.Year());
129 CDebug("Month is {}", now.Month());
130 CDebug("Day is {}", now.Day());
131 CDebug("Hour is {}", now.Hour());
132 CDebug("Day number is {}", now.YearDay());
133
134 CDebug("from_url = {}", instance.from_url.c_str());
135 CDebug("to_url = {}", instance.to_url.c_str());
136
137 // Turn off the cache for testing
138 // proxy.config.http.cache.http.set(1);
139 // control.cache.nostore.set(true);
140
141 CDebug("Int config cache.http = {}", proxy.config.http.cache.http.Get());
142 CDebug("Float config cache.heuristic_lm_factor = {}", proxy.config.http.cache.heuristic_lm_factor.Get());
143 CDebug("String config http.response_server_str = {}", proxy.config.http.response_server_str.GetSV(context));
144 CDebug("X-Miles = {}", client.request["X-Miles"]);
145 CDebug("random(1000) = {}", cripts::Random(1000));
146
147 auto old_port = urls.request.port;
148
149 CDebug("Method is {}", client.request.method);
150 CDebug("Scheme is {}", urls.request.scheme);
151 CDebug("Host is {}", urls.request.host);
152 CDebug("Port is {}", urls.request.port);
153 CDebug("Path is {}", urls.request.path);
154 CDebug("Path[1] is {}", urls.request.path[1]);
155 CDebug("Query is {}", urls.request.query);
156
157 auto testing_trim = urls.request.path.trim();
158
159 CDebug("Trimmed path is {}", testing_trim);
160
161 if (urls.request.query["foo"] > 100) {
162 CDebug("Query[foo] is > 100");
163 }
164
165 if (urls.request.path == "some/url" || urls.request.path[0] == "other") {
166 CDebug("The path comparison triggered");
167 }
168
169 urls.request.host = "foobar.com";
170 urls.request.port = "81";
171 urls.request.port = old_port;
172
173 // TXN data slots
174 txn_data[0] = true;
175 txn_data[1] = 17;

Callers

nothing calls this directly

Calls 15

RandomClass · 0.85
RegexClass · 0.85
EpochMethod · 0.80
YearMethod · 0.80
MonthMethod · 0.80
DayMethod · 0.80
HourMethod · 0.80
YearDayMethod · 0.80
IncrementMethod · 0.80
GaugeClass · 0.50
CounterClass · 0.50
IPMethod · 0.45

Tested by

no test coverage detected