httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roy Fielding <field...@hyperreal.com>
Subject cvs commit: apache/src CHANGES mod_negotiation.c
Date Fri, 14 Mar 1997 03:27:35 GMT
fielding    97/03/13 19:27:34

  Modified:    src       CHANGES mod_negotiation.c
  Log:
  Negotiation changes: Don't output empty content-type in variant list;
  Output charset in variant list; Return sooner from handle_multi() if
  no variants found; Add handling of '*' wildcard in Accept-Charset.
  
  Submitted by: Petr Lampa and Paul Sutton
  Reviewed by: Roy Fielding, Jim Jagielski
  
  Revision  Changes    Path
  1.197     +5 -0      apache/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /export/home/cvs/apache/src/CHANGES,v
  retrieving revision 1.196
  retrieving revision 1.197
  diff -C3 -r1.196 -r1.197
  *** CHANGES	1997/03/11 06:04:38	1.196
  --- CHANGES	1997/03/14 03:27:31	1.197
  ***************
  *** 1,5 ****
  --- 1,10 ----
    Changes with Apache 1.2b8
    
  +   *) Negotiation changes: Don't output empty content-type in variant list;
  +      Output charset in variant list; Return sooner from handle_multi() if
  +      no variants found; Add handling of '*' wildcard in Accept-Charset.
  +      [Petr Lampa and Paul Sutton]
  + 
      *) Memory allocation problem in push_array() -- it would corrupt memory
         when nalloc==0.  [Kai Risku <krisku@tf.hut.fi> and Roy Fielding]
    
  
  
  
  1.35      +23 -14    apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -C3 -r1.34 -r1.35
  *** mod_negotiation.c	1997/03/07 14:15:43	1.34
  --- mod_negotiation.c	1997/03/14 03:27:32	1.35
  ***************
  *** 1274,1291 ****
        int i;
        accept_rec *accept_recs = (accept_rec *)neg->accept_charsets->elts;
        char *charset = variant->content_charset;
  ! 
  !     if (!charset)
  !         return;                 /* variant has no charset */
    
        /* if no Accept-Charset: header, leave quality alone (will
         * remain at the default value of 1) */
        if (!neg->accept_charsets || neg->accept_charsets->nelts == 0) 
            return;
    
  !     if (!*charset || !strcmp(charset, "iso-8859-1"))
  !         return;                 /* default charset always ok */
  ! 
    
        /*
         * Go through each of the items on the Accept-Charset: header,
  --- 1274,1287 ----
        int i;
        accept_rec *accept_recs = (accept_rec *)neg->accept_charsets->elts;
        char *charset = variant->content_charset;
  !     accept_rec *star = NULL;
    
        /* if no Accept-Charset: header, leave quality alone (will
         * remain at the default value of 1) */
        if (!neg->accept_charsets || neg->accept_charsets->nelts == 0) 
            return;
    
  !     if (charset == NULL || !*charset) charset = "iso-8859-1";
    
        /*
         * Go through each of the items on the Accept-Charset: header,
  ***************
  *** 1299,1307 ****
            if (!strcmp(type->type_name, charset)) {
                variant->charset_quality = type->quality;
                return;
            }
        }
  !     variant->charset_quality = 0.0;
    }
    
    /* For a given variant, find the best matching Accept: header
  --- 1295,1316 ----
            if (!strcmp(type->type_name, charset)) {
                variant->charset_quality = type->quality;
                return;
  +         } else
  +         if (strcmp(type->type_name, "*") == 0) {
  +             star = type;    
            }
        }
  !     /* No explicit match */
  !     if (star) {
  !         variant->charset_quality = star->quality;
  !         return;
  !     }
  !     /* If this variant is in charset iso-8859-1, the default is 1.0 */
  !     if (strcmp(charset, "iso-8859-1") == 0) {
  !         variant->charset_quality = 1.0;
  !     } else {
  !         variant->charset_quality = 0.0;
  !     }
    }
    
    /* For a given variant, find the best matching Accept: header
  ***************
  *** 1737,1743 ****
        for (i = 0; i < neg->avail_vars->nelts; ++i) {
            var_rec *variant = &((var_rec *)neg->avail_vars->elts)[i];
            char *filename = variant->file_name ? variant->file_name : "";
  -         char *content_type = variant->type_name ? variant->type_name : "";
            array_header *languages = variant->content_languages;
            char *description = variant->description ? variant->description : "";
    
  --- 1746,1751 ----
  ***************
  *** 1746,1757 ****
    	 * 'English'). */
            t = pstrcat(r->pool, t, "<li><a href=\"", filename, "\">", 
                        filename, "</a> ", description, NULL);
  ! 	if (content_type)
  ! 	    t = pstrcat(r->pool, t, " type ", content_type, NULL);
    	if (languages && languages->nelts)
  ! 	    t = pstrcat(r->pool, t, " language ",
    			merge_string_array(r->pool, languages, ", "),
    			NULL);
    	t = pstrcat(r->pool, t, "\n", NULL);
        }
        t = pstrcat(r->pool, t, "</ul>\n", NULL);
  --- 1754,1767 ----
    	 * 'English'). */
            t = pstrcat(r->pool, t, "<li><a href=\"", filename, "\">", 
                        filename, "</a> ", description, NULL);
  ! 	if (variant->type_name && *variant->type_name)
  ! 	    t = pstrcat(r->pool, t, ", type ", variant->type_name, NULL);
    	if (languages && languages->nelts)
  ! 	    t = pstrcat(r->pool, t, ", language ",
    			merge_string_array(r->pool, languages, ", "),
    			NULL);
  + 	if (variant->content_charset && *variant->content_charset)
  + 	    t = pstrcat(r->pool, t, ", charset ", variant->content_charset, NULL);
    	t = pstrcat(r->pool, t, "\n", NULL);
        }
        t = pstrcat(r->pool, t, "</ul>\n", NULL);
  ***************
  *** 1897,1909 ****
            }
            return res;
        }
  !     
        maybe_add_default_encodings(neg,
                                    r->method_number != M_GET
                                      || r->args || r->path_info);
        
  -     if (neg->avail_vars->nelts == 0) return DECLINED;
  - 
        na_result = best_match(neg, &best);
        if (na_result == na_list) {
            /*
  --- 1907,1918 ----
            }
            return res;
        }
  !     if (neg->avail_vars->nelts == 0) return DECLINED;
  ! 
        maybe_add_default_encodings(neg,
                                    r->method_number != M_GET
                                      || r->args || r->path_info);
        
        na_result = best_match(neg, &best);
        if (na_result == na_list) {
            /*
  
  
  

Mime
View raw message