httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexei Kosut <ako...@hyperreal.com>
Subject cvs commit: apache/src mod_negotiation.c
Date Thu, 15 Aug 1996 20:12:13 GMT
akosut      96/08/15 13:12:12

  Modified:    src       mod_negotiation.c
  Log:
  If the client doesn't send q-values in Accept: give wilcards arbitrarily
  low values, so that "Accept: image/gif, */*" on a request with variants
  image/gif; qs=0.3 and image/png; qs=0.7 doesn't end up with the PNG.
  
  Revision  Changes    Path
  1.15      +27 -3     apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -C3 -r1.14 -r1.15
  *** mod_negotiation.c	1996/08/15 19:26:59	1.14
  --- mod_negotiation.c	1996/08/15 20:12:10	1.15
  ***************
  *** 185,190 ****
  --- 185,191 ----
        pool *pool;
        request_rec *r;
        char *dir_name;
  +     int accept_q;	/* Do any of the Accept: headers have a q-value ? */
        
        array_header *accepts;	/* accept_recs */
        array_header *accept_encodings;	/* accept_recs */
  ***************
  *** 342,348 ****
  --- 343,352 ----
    {
        negotiation_state *new =
            (negotiation_state *)pcalloc (r->pool, sizeof (negotiation_state));
  +     accept_rec *elts;
        table *hdrs = r->headers_in;
  +     
  +     int i;
    
        new->pool = r->pool;
        new->r = r;
  ***************
  *** 355,360 ****
  --- 359,374 ----
          do_header_line (r->pool, table_get (hdrs, "Accept-language"));
        new->avail_vars = make_array (r->pool, 40, sizeof (var_rec));
    
  +     /* Now we check for q-values. If they're all 1.0, we assume the
  +      * client is "broken", and we are allowed to fiddle with the
  +      * values later. Otherwise, we leave them alone.
  +      */
  +     
  +     elts = (accept_rec *)new->accepts->elts;
  + 
  +     for (i = 0; i < new->accepts->nelts; ++i)
  + 	if (elts[i].quality < 1.0) new->accept_q = 1;
  + 
        return new;
    }
    
  ***************
  *** 944,960 ****
    	for (j = 0; j < neg->avail_vars->nelts; ++j) {
    	    
    	    var_rec *variant = &avail_recs[j];
  ! 	    float q = type->quality * variant->quality;
  ! 		
    	    /* If we've already rejected this variant, don't waste time */
    	    
  ! 	    if (q == 0.0) continue;	
    	    
    	    /* If media types don't match, forget it.
    	     * (This includes the level check).
    	     */
    	    
    	    if (!mime_match(type, variant)) continue;
    
    	    /* Check maxbytes */
    		
  --- 958,984 ----
    	for (j = 0; j < neg->avail_vars->nelts; ++j) {
    	    
    	    var_rec *variant = &avail_recs[j];
  ! 	    float q, quality = type->quality;
  ! 
    	    /* If we've already rejected this variant, don't waste time */
    	    
  ! 	    if (variant->quality == 0.0) continue;	
    	    
    	    /* If media types don't match, forget it.
    	     * (This includes the level check).
    	     */
    	    
    	    if (!mime_match(type, variant)) continue;
  + 
  + 	    /* If we are allowed to mess with the q-values,
  + 	     * make wildcards very low, so we have a low chance
  + 	     * of ending up with them if there's something better.
  + 	     */
  + 	    
  + 	    if (!neg->accept_q && variant->mime_stars == 1) quality = 0.01;
  + 	    if (!neg->accept_q && variant->mime_stars == 2) quality = 0.02;
  + 
  + 	    q = quality * variant->quality;
    
    	    /* Check maxbytes */
    		
  
  
  

Mime
View raw message