httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Sutton <p...@ukweb.com>
Subject PR#94: bug in content negotiation
Date Fri, 30 May 1997 16:12:45 GMT
PR#94 (from ages ago) actually tweaks a bug introduced in 1.2b8.

The problem is that if you have multiple variants that are otherwise
equal, Apache prefers the _last_ listed variant in the type map (or the
last file read from the file system). This contradicts all the other tests
- and the documented algorythm - which prefer the first variant out of
equally acceptable ones. The bug was introduced in a patch to prefer
non-iso-8859-1 charsets, but is has the side-effect of always picking the
last equally acceptable variant. The equal variants might all have no
charset at all or all by iso-8859-1. The effect when no variants have
charsets is particularly unwelcome, and causes the #94 bug. This bug has
the effect of never allowing the final test for file size to be applied. 

In PR#94, the user had a jpg and gif (listed in that order), and under
Apache prior to 1.2b7, the jpg would have been chosen because of its
smaller filesize. Currently the gif is chosen, because it is listed last
and because it has no charset (if all variant are given charsets and none
of the charsets are iso-8859-1 the negotiation works ok). But many file
types, such as images, do not have character sets. 

The patch below attempts to fix the problem. It only picks a later-listed
variant as the best match if

    The charset qualities of both variant and best-match-so-far are equal
AND the current variant has a charset which is not iso-8859-1
AND (the previous best match had a no charset OR a charset of iso-8859-1)

This now prefers the _first_ variant with matching charsets, or if no
charsets are present allows a fall-through to the file-size checking code. 

//pcs

*** mod_negotiation.c.dist	Fri May 30 16:04:35 1997
--- mod_negotiation.c	Fri May 30 17:05:28 1997
***************
*** 1439,1446 ****
          /* If the best variant's charset is ISO-8859-1 and this variant has
             the same charset quality, then we prefer this variant */
          if (variant->charset_quality == best->charset_quality &&
!             (best->content_charset == NULL || *best->content_charset == 0 ||
!             strcmp(best->content_charset, "iso-8859-1") == 0)) {
              *p_bestq = q;
              return 1;
  	}
--- 1439,1449 ----
          /* If the best variant's charset is ISO-8859-1 and this variant has
             the same charset quality, then we prefer this variant */
          if (variant->charset_quality == best->charset_quality &&
!             (variant->content_charset != NULL &&
!              strcmp(variant->content_charset, "iso-8859-1") != 0) &&
!             (best->content_charset == NULL ||
!              *best->content_charset == '\0' ||
!              strcmp(best->content_charset, "iso-8859-1") == 0)) {
              *p_bestq = q;
              return 1;
  	}
***************
*** 1538,1546 ****
      /* If the best variant's charset is ISO-8859-1 and this variant has
         the same charset quality, then we prefer this variant */
      if (variant->charset_quality > best->charset_quality ||
!         (variant->charset_quality == best->charset_quality &&
!         (best->content_charset == NULL || *best->content_charset == 0 ||
!         strcmp(best->content_charset, "iso-8859-1") == 0))) {
          *p_bestq = q;
          return 1;
      }
--- 1541,1551 ----
      /* If the best variant's charset is ISO-8859-1 and this variant has
         the same charset quality, then we prefer this variant */
      if (variant->charset_quality > best->charset_quality ||
!         (variant->content_charset != NULL &&
!          strcmp(variant->content_charset, "iso-8859-1") != 0) &&
!         (best->content_charset == NULL ||
!          *best->content_charset == '\0' ||
!          strcmp(best->content_charset, "iso-8859-1") == 0)) {
          *p_bestq = q;
          return 1;
      }


Mime
View raw message