From: dgaudet Date: Fri, 27 Jun 1997 02:20:19 +0000 (+0000) Subject: PR#94: Content negot fails unless each varient has a charset X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3015a4ac2f0e4e0164ca2c3a4aed5a07d4cfcca;p=thirdparty%2Fapache%2Fhttpd.git 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 --- diff --git a/APACHE_1_2_X/src/CHANGES b/APACHE_1_2_X/src/CHANGES index 4c0dd0e6378..4064a70e009 100644 --- a/APACHE_1_2_X/src/CHANGES +++ b/APACHE_1_2_X/src/CHANGES @@ -1,4 +1,8 @@ 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 diff --git a/APACHE_1_2_X/src/modules/standard/mod_negotiation.c b/APACHE_1_2_X/src/modules/standard/mod_negotiation.c index 02be3f10e38..22645b66a42 100644 --- a/APACHE_1_2_X/src/modules/standard/mod_negotiation.c +++ b/APACHE_1_2_X/src/modules/standard/mod_negotiation.c @@ -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,8 +1442,11 @@ 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 || - strcmp(best->content_charset, "iso-8859-1") == 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,9 +1544,11 @@ 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 || - strcmp(best->content_charset, "iso-8859-1") == 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);