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

Function does_language_range_match

src/iocore/cache/HttpTransactCache.cc:1052–1066  ·  view source on GitHub ↗

Match request Accept-Language with response Content-Language. Language matching is a little more complicated because of "ranges". First, no Accept-Language header or no Content-Language headers match with q of 1. Otherwise, loop over Content-Languages. If there is a match with a language in the Accept-Language field, keep track of how many characters were in the value. The q value for t

Source from the content-addressed store, hash-verified

1050
1051*/
1052static inline bool
1053does_language_range_match(const char *range1, const char *range2)
1054{
1055 while (*range1 && *range2 && (ParseRules::ink_tolower(*range1) == ParseRules::ink_tolower(*range2))) {
1056 range1 += 1;
1057 range2 += 1;
1058 }
1059
1060 // matches if range equals tag, or if range is a lang prefix of tag
1061 if ((((*range1 == NUL) && (*range2 == NUL)) || ((*range1 == NUL) && (*range2 == '-')))) {
1062 return true;
1063 }
1064
1065 return false;
1066}
1067
1068static inline bool
1069match_accept_content_language(const char *c_raw, MIMEField *accept_field, bool *wildcard_present, float *wildcard_q, float *q,

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected