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

Function match_accept_content_language

src/iocore/cache/HttpTransactCache.cc:1068–1119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1066}
1067
1068static inline bool
1069match_accept_content_language(const char *c_raw, MIMEField *accept_field, bool *wildcard_present, float *wildcard_q, float *q,
1070 int *a_range_length)
1071{
1072 const char *a_raw;
1073 int a_raw_len;
1074 StrList a_values_list;
1075 Str *a_value;
1076
1077 ink_assert(accept_field != nullptr);
1078
1079 // loop over each language-range pattern //
1080 // TODO: Should we check the return value (count) here?
1081 accept_field->value_get_comma_list(&a_values_list);
1082
1083 for (a_value = a_values_list.head; a_value; a_value = a_value->next) {
1084 a_raw = a_value->str;
1085 a_raw_len = a_value->len;
1086
1087 char *a_range;
1088 StrList a_param_list;
1089
1090 HttpCompat::parse_semicolon_list(&a_param_list, a_raw, a_raw_len);
1091 float tq = HttpCompat::find_Q_param_in_strlist(&a_param_list);
1092
1093 /////////////////////////////////////////////////////////////////////
1094 // This algorithm is a bit weird --- the resulting Q factor is //
1095 // the Q value corresponding to the LONGEST range field that //
1096 // matched, or if none matched, then the Q value of any asterisk. //
1097 // Also, if the lang value is "", meaning that no Content-Language //
1098 // was specified, this document matches all accept headers. //
1099 /////////////////////////////////////////////////////////////////////
1100 if (a_param_list.head) {
1101 a_range = const_cast<char *>(a_param_list.head->str);
1102 *a_range_length = a_param_list.head->len;
1103 } else {
1104 continue;
1105 }
1106
1107 if (is_asterisk(a_range)) {
1108 *wildcard_present = true;
1109 *wildcard_q = HttpCompat::find_Q_param_in_strlist(&a_param_list);
1110 return true;
1111 } else if (does_language_range_match(a_range, c_raw)) {
1112 *q = tq;
1113 return true;
1114 } else {
1115 }
1116 }
1117
1118 return false;
1119}
1120
1121// FIX: This code is icky, and i suspect wrong in places, particularly
1122// because parts of match_accept_content_language are commented out.

Calls 3

is_asteriskFunction · 0.85
value_get_comma_listMethod · 0.80

Tested by

no test coverage detected