pcs         98/12/04 09:37:14

  Modified:    htdocs/manual content-negotiation.html
               src      CHANGES
               src/modules/standard mod_negotiation.c
  Log:
  Fix negotiation so that we prefer an encoded variant over an unencoded
  variant if the user-agent explicitly says it can accept that encoding.
  Previously we always preferred the unencoded variant.
  
  PR:           3447
  Submitted by: Paul Ausbeck <[EMAIL PROTECTED]>
  Reviewed by:  Paul Sutton
  
  Revision  Changes    Path
  1.19      +6 -3      apache-1.3/htdocs/manual/content-negotiation.html
  
  Index: content-negotiation.html
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/htdocs/manual/content-negotiation.html,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- content-negotiation.html  1998/09/17 14:14:47     1.18
  +++ content-negotiation.html  1998/12/04 17:37:06     1.19
  @@ -301,9 +301,12 @@
   <LI>Select the variants with the highest 'level' media parameter
     (used to give the version of text/html media types).
   
  -<LI>Select only unencoded variants, if there is a mix of encoded
  -  and non-encoded variants. If either all variants are encoded
  -  or all variants are not encoded, select all.
  +<LI>Select the variants with the best encoding. If there are
  +  variants with an encoding that is acceptable to the user-agent,
  +  select only these variants. Otherwise if there is a mix of encoded
  +  and non-encoded variants, select only the unencoded variants.
  +  If either all variants are encoded or all variants are not encoded, 
  +  select all variants.
   
   <LI>Select only variants with acceptable charset media parameters,
     as given on the Accept-Charset header line. Charset ISO-8859-1
  
  
  
  1.1160    +6 -0      apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.1159
  retrieving revision 1.1160
  diff -u -r1.1159 -r1.1160
  --- CHANGES   1998/12/02 19:24:46     1.1159
  +++ CHANGES   1998/12/04 17:37:09     1.1160
  @@ -1,4 +1,10 @@
   Changes with Apache 1.3.4
  +
  +  *) Fix negotiation so that we prefer an encoded variant over an
  +     unencoded variant if the user-agent explicitly says it can
  +     accept that encoding. Previously we always preferred the unencoded
  +     variant.
  +     [Paul Ausbeck <[EMAIL PROTECTED]>, Paul Sutton] PR#3447
    
     *) Fix APXS tool: query variables LIBS_SHLIB and TARGET were not recognized
        and the usage page was inconsistent with the functionality and manpage.
  
  
  
  1.86      +39 -4     apache-1.3/src/modules/standard/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_negotiation.c,v
  retrieving revision 1.85
  retrieving revision 1.86
  diff -u -r1.85 -r1.86
  --- mod_negotiation.c 1998/11/23 09:56:38     1.85
  +++ mod_negotiation.c 1998/12/04 17:37:12     1.86
  @@ -1454,6 +1454,33 @@
               || !strcmp(enc, "binary"));
   }
   
  +/*
  + * set_encoding_quality determines whether the encoding for a particular
  + * variant is acceptable for the user-agent. There are no q-values on
  + * encodings, so this is set as an integer value variant->encoding_quality.
  + *
  + * The rules for encoding are that if the user-agent does not supply
  + * any Accept-Encoding header, then all encodings are allowed. If
  + * there is an empty Accept-Encoding header, then no encodings are 
  + * acceptable. If there is a non-empty Accept-Encoding header, then
  + * any of the listed encodings are acceptable, as well as no encoding.
  + *
  + * In the later case, we assume that it is preferable to return a
  + * suitable encoded variant in preference to an unencoded variant.
  + *
  + * The variant with the higher value should be prefered over variants
  + * with lower values. The values used are 0 if this variant is
  + * unacceptable (if it is encoded but the user-agent does not accept
  + * this encoding or any encodings), 1 if this variant is acceptable to
  + * the user-agent either because this variant is unencoded or the
  + * user-agent does not give an Accept-Encoding header, or 2 if this
  + * variant is encoding and the user-agent specifically asks for this
  + * encoding on its Accept-Encoding header. The effect of this is to
  + * prefer encoded variants when they user-agent explicitly says that
  + * the encoding is acceptable, otherwise encoded and unencoded
  + * variants get the same encoding_quality. 
  + */
  +
   static void set_encoding_quality(negotiation_state *neg, var_rec *variant)
   {
       int i;
  @@ -1487,7 +1514,7 @@
           }
   
           if (!strcmp(name, enc)) {
  -            variant->encoding_quality = 1;
  +            variant->encoding_quality = 2;
               return;
           }
       }
  @@ -1666,10 +1693,18 @@
           *p_bestq = q;
           return 1;
       }
  +
  +    /* Prefer the highest value for encoding_quality. If they are 
  +     * equal, prefer the variant without any encoding.
  +     */
  +    if (variant->encoding_quality < best->encoding_quality) {
  +     return 0;
  +    }
  +    if (variant->encoding_quality > best->encoding_quality) {
  +     *p_bestq = q;
  +     return 1;
  +    }
   
  -    /* encoding -- can only be 1 or 0, and if 0 we eliminated this
  -     * variant at the start of this function. However we 
  -     * prefer variants with no encoding over those with encoding */
       if (best->content_encoding == NULL && variant->content_encoding) {
           return 0;
       }
  
  
  

Reply via email to