Commit 6b021a7a authored by dgaudet's avatar dgaudet
Browse files

PR#94: Content negot fails unless each varient has a charset

Reviewed by:	Dean, Alexei
Submitted by:	Paul Sutton
Obtained from:


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3@78386 13f79535-47bb-0310-9956-ffa450edef68
parent 64079703
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
Changes with Apache 1.2.1
  
  *) If an object has multiple variants that are otherwise equal Apache
     would prefer the last listed variant rather than the first.
     [Paul Sutton] PR#94

  *) "HostnameLookups" now defaults to off because it is far better for
     the net if we require people that actually need this data to
     enable it.  [Linus Torvalds]
+19 −11
Original line number Diff line number Diff line
@@ -642,17 +642,20 @@ char *lcase_header_name_return_body (char *header, request_rec *r)
    return cp;
}

int read_type_map (negotiation_state *neg, char *map_name)
static int read_type_map (negotiation_state *neg, request_rec *rr)
{
    request_rec *r = neg->r;
    FILE *map = pfopen (neg->pool, map_name, "r");

    FILE *map;
    char buffer[MAX_STRING_LEN];
    enum header_state hstate;
    struct var_rec mime_info;
    
    if (rr->status != HTTP_OK) {
	return rr->status;
    }
    map = pfopen (neg->pool, rr->filename, "r");
    if (map == NULL) {
        log_reason("cannot access type map file", map_name, r);
        log_reason("cannot access type map file", rr->filename, r);
	return FORBIDDEN;
    }

@@ -780,7 +783,7 @@ int read_types_multi (negotiation_state *neg)
	    closedir(dirp);
	    
	    neg->avail_vars->nelts = 0;
	    return read_type_map (neg, sub_req->filename);
	    return read_type_map (neg, sub_req);
	}
	
	/* Have reasonable variant --- gather notes.
@@ -1439,7 +1442,10 @@ int is_variant_better_na(negotiation_state *neg, var_rec *variant, var_rec *best
        /* 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 ||
            (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,8 +1544,10 @@ float is_variant_better(negotiation_state *neg, var_rec *variant, var_rec *best,
    /* 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 ||
	((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;
@@ -1850,7 +1858,7 @@ int handle_map_file (request_rec *r)
    
    char *udir;
    
    if ((res = read_type_map (neg, r->filename))) return res;
    if ((res = read_type_map (neg, r))) return res;
    
    maybe_add_default_encodings(neg, 0);