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

Method do_vary_header_values_match

src/proxy/hdrs/HttpCompat.cc:434–469  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////////// bool HttpCompat::do_vary_header_values_match(MIMEField *hv1, MIMEField *hv2) This routine takes two HTTP header fields and determines if their values "match", as in section 14.43 of RFC2068: "When the cache receives a subsequent request whose Request-URI specifies one or more cache entries including a Vary header, the cac

Source from the content-addressed store, hash-verified

432//
433//////////////////////////////////////////////////////////////////////////////
434bool
435HttpCompat::do_vary_header_values_match(MIMEField *hdr1, MIMEField *hdr2)
436{
437 // If both headers are missing, the headers match.
438 if (!hdr1 && !hdr2) {
439 return true;
440 }
441
442 // If one header is missing, the headers do not match.
443 if (!hdr1 || !hdr2) {
444 return false;
445 }
446
447 // Make sure both headers have the same number of comma-
448 // separated elements.
449 HdrCsvIter iter1, iter2;
450 if (iter1.count_values(hdr1) != iter2.count_values(hdr2)) {
451 return false;
452 }
453
454 int hdr1_val_len, hdr2_val_len;
455 const char *hdr1_val = iter1.get_first(hdr1, &hdr1_val_len);
456 const char *hdr2_val = iter2.get_first(hdr2, &hdr2_val_len);
457
458 while (hdr1_val || hdr2_val) {
459 if (!hdr1_val || !hdr2_val || hdr1_val_len != hdr2_val_len ||
460 ParseRules::strncasecmp_eow(hdr1_val, hdr2_val, hdr1_val_len) == false) {
461 return false;
462 }
463
464 hdr1_val = iter1.get_next(&hdr1_val_len);
465 hdr2_val = iter2.get_next(&hdr2_val_len);
466 }
467
468 return true;
469}
470
471//////////////////////////////////////////////////////////////////////////////
472//

Callers

nothing calls this directly

Calls 3

count_valuesMethod · 0.80
get_firstMethod · 0.80
get_nextMethod · 0.80

Tested by

no test coverage detected