TODO: This used to take a length for c_raw, but that was never used, so removed it from the prototype.
| 856 | |
| 857 | // TODO: This used to take a length for c_raw, but that was never used, so removed it from the prototype. |
| 858 | static inline bool |
| 859 | match_accept_content_encoding(const char *c_raw, MIMEField *accept_field, bool *wildcard_present, float *wildcard_q, float *q) |
| 860 | { |
| 861 | Str *a_value; |
| 862 | const char *a_raw; |
| 863 | StrList a_values_list; |
| 864 | |
| 865 | if (!accept_field) { |
| 866 | return false; |
| 867 | } |
| 868 | // loop over Accept-Encoding elements, looking for match // |
| 869 | // TODO: Should we check the return value (count) here? |
| 870 | accept_field->value_get_comma_list(&a_values_list); |
| 871 | |
| 872 | for (a_value = a_values_list.head; a_value; a_value = a_value->next) { |
| 873 | char *a_encoding = nullptr; |
| 874 | StrList a_param_list; |
| 875 | |
| 876 | // Get the raw string to the current comma-sep Accept-Charset field value |
| 877 | a_raw = a_value->str; |
| 878 | |
| 879 | // break Accept-Encoding piece into semi-colon separated parts // |
| 880 | HttpCompat::parse_semicolon_list(&a_param_list, a_raw); |
| 881 | if (a_param_list.head) { |
| 882 | a_encoding = const_cast<char *>(a_param_list.head->str); |
| 883 | } else { |
| 884 | continue; |
| 885 | } |
| 886 | |
| 887 | if (is_asterisk(a_encoding)) { |
| 888 | *wildcard_present = true; |
| 889 | *wildcard_q = HttpCompat::find_Q_param_in_strlist(&a_param_list); |
| 890 | return true; |
| 891 | } else if (does_encoding_match(a_encoding, c_raw)) { |
| 892 | // if type matches, get the Q factor // |
| 893 | float tq; |
| 894 | tq = HttpCompat::find_Q_param_in_strlist(&a_param_list); |
| 895 | *q = (tq > *q ? tq : *q); |
| 896 | |
| 897 | return true; |
| 898 | } else { |
| 899 | // so this c_raw value did not match this a_raw value. big deal. |
| 900 | } |
| 901 | } |
| 902 | return false; |
| 903 | } |
| 904 | |
| 905 | float |
| 906 | HttpTransactCache::calculate_quality_of_accept_encoding_match(MIMEField *accept_field, MIMEField *content_field, |
no test coverage detected