///////////////////////////////////////////////////////////////////////// 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
| 432 | // |
| 433 | ////////////////////////////////////////////////////////////////////////////// |
| 434 | bool |
| 435 | HttpCompat::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 | // |
nothing calls this directly
no test coverage detected