@@ -979,38 +979,60 @@ HttpTransactCache::calculate_quality_of_accept_encoding_match(MIMEField *accept_
979979 if (!content_field) {
980980 if (!match_accept_content_encoding (" identity" , accept_field, &wildcard_present, &wildcard_q, &q)) {
981981 // CE was not returned, and AE does not have identity
982+ if (match_content_encoding (accept_field, " gzip" ) and match_content_encoding (cached_accept_field, " gzip" )) {
983+ return 1 .0f ;
984+ }
982985 goto encoding_wildcard;
983986 }
984- } else {
985- // Handle multiple content encodings - use minimum quality
986- float min_q = 1.0 ; // Start with maximum quality
987- bool found_match = false ;
987+ // use q from identity match
988988
989+ } else {
990+ // "Accept-encoding must correctly handle multiple content encoding"
991+ // The combined quality factor is the product of all quality factors.
992+ // (Note that there may be other possible choice, eg, min(),
993+ // but I think multiplication is the best.)
994+ // For example, if "content-encoding: a, b", and quality factors
995+ // of a and b (in accept-encoding header) are q_a and q_b, resp,
996+ // then the combined quality factor is (q_a * q_b).
997+ // If any one of the content-encoding is not matched,
998+ // then the q value will not be changed.
999+ float combined_q = 1.0 ;
9891000 for (c_value = c_values_list.head ; c_value; c_value = c_value->next ) {
9901001 float this_q = -1.0 ;
9911002 if (!match_accept_content_encoding (c_value->str , accept_field, &wildcard_present, &wildcard_q, &this_q)) {
9921003 goto encoding_wildcard;
9931004 }
994- if (this_q >= 0.0 ) {
995- found_match = false ;
996- if (this_q < min_q) {
997- min_q = this_q;
998- }
999- }
1000- }
1001- if (found_match) {
1002- q = min_q;
1003- } else {
1004- q = -1.0 ;
1005+ combined_q *= this_q;
10051006 }
1007+ q = combined_q;
10061008 }
10071009
10081010encoding_wildcard:
1011+ // match the wildcard now //
10091012 if ((q == -1.0 ) && (wildcard_present == true )) {
1010- return wildcard_q;
1013+ q = wildcard_q;
10111014 }
1012-
1013- return q;
1015+ // ///////////////////////////////////////////////////////////////////////
1016+ // there was an Accept-Encoding, but it didn't match anything, at //
1017+ // any quality level --- if this is an identity-coded document, that's //
1018+ // still okay, but otherwise, this is just not a match at all. //
1019+ // ///////////////////////////////////////////////////////////////////////
1020+ if ((q == -1.0 ) && is_identity_encoding) {
1021+ if (match_content_encoding (accept_field, " gzip" )) {
1022+ if (match_content_encoding (cached_accept_field, " gzip" )) {
1023+ return 1 .0f ;
1024+ } else {
1025+ // always try to fetch GZIP content if we have not tried sending AE before
1026+ return -1 .0f ;
1027+ }
1028+ } else if (cached_accept_field && !match_content_encoding (cached_accept_field, " gzip" )) {
1029+ return 0 .001f ;
1030+ } else {
1031+ return -1 .0f ;
1032+ }
1033+ }
1034+ // q = (float)-1.0;
1035+ return (q);
10141036}
10151037
10161038/* *
0 commit comments