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 18:36:47 GMT
akosut      96/08/15 11:36:46

  Modified:    src       mod_negotiation.c
  Log:
  Fix Vary mechanism to be more correct in how it determines the contents
  of the Vary header.
  
  Revision  Changes    Path
  1.12      +37 -17    apache/src/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -C3 -r1.11 -r1.12
  *** mod_negotiation.c	1996/07/28 22:40:55	1.11
  --- mod_negotiation.c	1996/08/15 18:36:42	1.12
  ***************
  *** 1022,1047 ****
    char *set_vary (pool *p, negotiation_state *neg)
    {
        var_rec *var_recs = (var_rec*)neg->avail_vars->elts;
  !     int i, accept_encoding = 0;
  !     int accept_language = 0;
  !     char *enc, *lang;
    
  !     /* Go through each variant and check for an encoding
  !      * or language (we always set "Accept", so no need to check).
         */
    
        for (i = 0; i < neg->avail_vars->nelts; ++i) {
  !         enc = var_recs[i].content_encoding;
  ! 	lang = var_recs[i].content_language;
  ! 
  !         if (!accept_encoding && !(!enc || !strcmp(enc, "")))
  ! 	    accept_encoding = 1;
  ! 	if (!accept_language && !(!lang || !strcmp(lang, "")))
  ! 	    accept_language = 1;
        }
    
  !     return pstrcat(p, "Accept", accept_encoding ? ", Accept-Encoding" : "",
  ! 		   accept_language ? ", Accept-Language" : "", NULL);
    }
    
    /****************************************************************
  --- 1022,1064 ----
    char *set_vary (pool *p, negotiation_state *neg)
    {
        var_rec *var_recs = (var_rec*)neg->avail_vars->elts;
  !     int i;
  !     int accept_type, accept_enc, accept_lang;
  !     char *type, *enc, *lang;
  !     char *last_type, *last_enc, *last_lang;
    
  !     accept_type = accept_enc = accept_lang = 0;
  !     last_type = last_enc = last_lang = NULL;
  ! 
  !     /* Go through each variant and check for a differing
  !      * type, encoding or type.
         */
    
        for (i = 0; i < neg->avail_vars->nelts; ++i) {
  ! 	/* Ideally, we wouldn't have to do this, but strcmp(NULL, NULL)
  ! 	 * isn't legal
  ! 	 */
  ! 	type = var_recs[i].type_name ? var_recs[i].type_name : "";
  !         enc = var_recs[i].content_encoding ? var_recs[i].content_encoding : "";
  !        lang = var_recs[i].content_language ? var_recs[i].content_language : "";
  ! 
  ! 	if (!accept_type && last_type && strcmp(last_type, type))
  ! 	    accept_type = 1;
  ! 	else if (!accept_type && !last_type) last_type = type;
  ! 
  ! 	if (!accept_enc && last_enc && strcmp(last_enc, enc))
  ! 	    accept_enc = 1;
  ! 	else if (!accept_enc && !last_enc) last_enc = enc;
  ! 
  ! 	if (!accept_lang && last_lang && strcmp(last_lang, lang))
  ! 	    accept_lang = 1;
  ! 	else if (!accept_lang && !last_lang) last_lang = lang;
        }
    
  !     if (!accept_type && !accept_enc && !accept_lang) return NULL;
  !     else return 2 + pstrcat(p, accept_type ? ", Accept" : "",
  ! 			    accept_enc ? ", Accept-Encoding" : "",
  ! 			    accept_lang ? ", Accept-Language" : "", NULL);
    }
    
    /****************************************************************
  ***************
  *** 1055,1061 ****
        var_rec *best;
        int res;
        
  !     char *udir;
        
        if ((res = read_type_map (neg, r->filename))) return res;
        
  --- 1072,1078 ----
        var_rec *best;
        int res;
        
  !     char *vary, *udir;
        
        if ((res = read_type_map (neg, r->filename))) return res;
        
  ***************
  *** 1073,1079 ****
         */
        if (!do_cache_negotiated_docs(r->server) && (r->proto_num < 1001))
            r->no_cache = 1;
  !     table_merge(r->err_headers_out, "Vary", set_vary(r->pool, neg));
    
        udir = make_dirstr (r->pool, r->uri, count_dirs (r->uri));
        udir = escape_uri(r->pool, udir);
  --- 1090,1097 ----
         */
        if (!do_cache_negotiated_docs(r->server) && (r->proto_num < 1001))
            r->no_cache = 1;
  !     if ((vary = set_vary(r->pool, neg)))
  ! 	table_merge(r->err_headers_out, "Vary", vary);
    
        udir = make_dirstr (r->pool, r->uri, count_dirs (r->uri));
        udir = escape_uri(r->pool, udir);
  ***************
  *** 1086,1091 ****
  --- 1104,1110 ----
        negotiation_state *neg;
        var_rec *best;
        request_rec *sub_req;
  +     char *vary;
        int res;
        
        if (r->finfo.st_mode != 0 || !(allow_options (r) & OPT_MULTI))
  ***************
  *** 1124,1130 ****
        
        if (!do_cache_negotiated_docs(r->server) && (r->proto_num < 1001))
            r->no_cache = 1;
  !     table_merge(r->err_headers_out, "Vary", set_vary(r->pool, neg));
    
        r->filename = sub_req->filename;
        r->handler = sub_req->handler;
  --- 1143,1150 ----
        
        if (!do_cache_negotiated_docs(r->server) && (r->proto_num < 1001))
            r->no_cache = 1;
  !     if ((vary = set_vary(r->pool, neg)))
  ! 	table_merge(r->err_headers_out, "Vary", vary);
    
        r->filename = sub_req->filename;
        r->handler = sub_req->handler;
  
  
  

Mime
View raw message