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

Method Init

src/proxy/CacheControl.cc:235–345  ·  view source on GitHub ↗

Result CacheControlRecord::Init(matcher_line* line_info) matcher_line* line_info - contains parsed label/value pairs of the current cache.config line Returns NULL if everything is OK Otherwise, returns an error string that the caller MUST DEALLOCATE with free()

Source from the content-addressed store, hash-verified

233// DEALLOCATE with free()
234//
235Result
236CacheControlRecord::Init(matcher_line *line_info)
237{
238 int time_in;
239 const char *tmp;
240 char *label;
241 char *val;
242 bool d_found = false;
243
244 this->line_num = line_info->line_num;
245
246 // First pass for optional tweaks.
247 for (int i = 0; i < MATCHER_MAX_TOKENS && line_info->num_el; ++i) {
248 bool used = false;
249 label = line_info->line[0][i];
250 val = line_info->line[1][i];
251 if (!label) {
252 continue;
253 }
254
255 if (strcasecmp(label, TWEAK_CACHE_RESPONSES_TO_COOKIES) == 0) {
256 char *ptr = nullptr;
257 int v = strtol(val, &ptr, 0);
258 if (!ptr || v < 0 || v > 4) {
259 return Result::failure("Value for " TWEAK_CACHE_RESPONSES_TO_COOKIES " must be an integer in the range 0..4");
260 } else {
261 cache_responses_to_cookies = v;
262 }
263 used = true;
264 }
265
266 // Clip pair if used.
267 if (used) {
268 line_info->line[0][i] = nullptr;
269 --(line_info->num_el);
270 }
271 }
272
273 // Now look for the directive.
274 for (int i = 0; i < MATCHER_MAX_TOKENS; i++) {
275 label = line_info->line[0][i];
276 val = line_info->line[1][i];
277
278 if (label == nullptr) {
279 continue;
280 }
281
282 if (strcasecmp(label, "action") == 0) {
283 if (strcasecmp(val, "never-cache") == 0) {
284 directive = CC_NEVER_CACHE;
285 d_found = true;
286 } else if (strcasecmp(val, "standard-cache") == 0) {
287 directive = CC_STANDARD_CACHE;
288 d_found = true;
289 } else if (strcasecmp(val, "ignore-no-cache") == 0) {
290 directive = CC_IGNORE_NO_CACHE;
291 d_found = true;
292 } else if (strcasecmp(val, "ignore-client-no-cache") == 0) {

Callers 1

NewEntryMethod · 0.45

Calls 2

strcasecmpFunction · 0.85
processDurationStringFunction · 0.85

Tested by

no test coverage detected