randy 97/02/21 16:33:32
Modified: src CHANGES mod_negotiation.c
Log:
- replace protocol response numbers with symbols
- save variant-list into main request notes
- free allocated memory from subrequests
- merge notes, headers_out and err_headers_out
Reviewed by: Dean Gaudet, Randy Terbush, Marc Slemko
Submitted by: Petr Lampa
Revision Changes Path
1.178 +6 -0 apache/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /export/home/cvs/apache/src/CHANGES,v
retrieving revision 1.177
retrieving revision 1.178
diff -C3 -r1.177 -r1.178
*** CHANGES 1997/02/21 01:20:39 1.177
--- CHANGES 1997/02/22 00:33:29 1.178
***************
*** 1,5 ****
--- 1,11 ----
Changes with Apache 1.2b7
+ *) mod_negotiation fixes [Petr Lampa]
+ - replace protocol response numbers with symbols
+ - save variant-list into main request notes
+ - free allocated memory from subrequests
+ - merge notes, headers_out and err_headers_out
+
*) changed status check mask in proxy_http.c from "HTTP/#.# ### *" to
"HTTP/#.# ###*" to be more lenient about what we accept.
[Chuck Murcko]
1.33 +49 -14 apache/src/mod_negotiation.c
Index: mod_negotiation.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_negotiation.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -C3 -r1.32 -r1.33
*** mod_negotiation.c 1997/02/07 07:13:15 1.32
--- mod_negotiation.c 1997/02/22 00:33:29 1.33
***************
*** 763,769 ****
if (sub_req->handler && !sub_req->content_type)
sub_req->content_type = CGI_MAGIC_TYPE;
! if (sub_req->status != 200 || !sub_req->content_type) continue;
/* If it's a map file, we use that instead of the map
* we're building...
--- 763,769 ----
if (sub_req->handler && !sub_req->content_type)
sub_req->content_type = CGI_MAGIC_TYPE;
! if (sub_req->status != HTTP_OK || !sub_req->content_type) continue;
/* If it's a map file, we use that instead of the map
* we're building...
***************
*** 1761,1767 ****
void store_variant_list (request_rec *r, negotiation_state *neg)
{
! table_set (r->notes, "variant-list", make_variant_list (r, neg));
}
/* Called if we got a "Choice" response from the network algorithm.
--- 1761,1771 ----
void store_variant_list (request_rec *r, negotiation_state *neg)
{
! if (r->main == NULL) {
! table_set (r->notes, "variant-list", make_variant_list (r, neg));
! } else {
! table_set (r->main->notes, "variant-list", make_variant_list (r->main,
neg));
! }
}
/* Called if we got a "Choice" response from the network algorithm.
***************
*** 1777,1783 ****
if (!variant->sub_req) {
sub_req = sub_req_lookup_file(variant->file_name, r);
! if (sub_req->status != 200 && sub_req->status != 300)
return sub_req->status;
variant->sub_req = sub_req;
}
--- 1781,1787 ----
if (!variant->sub_req) {
sub_req = sub_req_lookup_file(variant->file_name, r);
! if (sub_req->status != HTTP_OK && sub_req->status !=
HTTP_MULTIPLE_CHOICES)
return sub_req->status;
variant->sub_req = sub_req;
}
***************
*** 1793,1799 ****
* the normal variant handling
*/
! if ((sub_req->status == 300) ||
(table_get(sub_req->headers_out, "Alternates")) ||
(table_get(sub_req->headers_out, "Content-Location")))
return VARIANT_ALSO_VARIES;
--- 1797,1803 ----
* the normal variant handling
*/
! if ((sub_req->status == HTTP_MULTIPLE_CHOICES) ||
(table_get(sub_req->headers_out, "Alternates")) ||
(table_get(sub_req->headers_out, "Content-Location")))
return VARIANT_ALSO_VARIES;
***************
*** 1870,1878 ****
int handle_multi (request_rec *r)
{
negotiation_state *neg;
! var_rec *best;
request_rec *sub_req;
int res;
int na_result; /* result of network algorithm */
if (r->finfo.st_mode != 0 || !(allow_options (r) & OPT_MULTI))
--- 1874,1883 ----
int handle_multi (request_rec *r)
{
negotiation_state *neg;
! var_rec *best, *avail_recs;
request_rec *sub_req;
int res;
+ int j;
int na_result; /* result of network algorithm */
if (r->finfo.st_mode != 0 || !(allow_options (r) & OPT_MULTI))
***************
*** 1880,1893 ****
neg = parse_accept_headers (r);
! if ((res = read_types_multi (neg))) 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) {
/*
--- 1885,1909 ----
neg = parse_accept_headers (r);
! if ((res = read_types_multi (neg))) {
! return_from_multi:
! /* free all allocated memory from subrequests */
! avail_recs = (var_rec *)neg->avail_vars->elts;
! for (j = 0; j < neg->avail_vars->nelts; ++j) {
! var_rec *variant = &avail_recs[j];
! if (variant->sub_req) {
! destroy_sub_req(variant->sub_req);
! }
! }
! 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) {
/*
***************
*** 1899,1905 ****
set_neg_headers(r, neg, na_list); /* set Alternates: and Vary: */
store_variant_list (r, neg);
! return MULTIPLE_CHOICES;
}
if (!best) {
--- 1915,1922 ----
set_neg_headers(r, neg, na_list); /* set Alternates: and Vary: */
store_variant_list (r, neg);
! res = MULTIPLE_CHOICES;
! goto return_from_multi;
}
if (!best) {
***************
*** 1907,1918 ****
set_neg_headers (r, neg, na_result);
store_variant_list (r, neg);
! return NOT_ACCEPTABLE;
}
if (na_result == na_choice)
! if ((res = setup_choice_response(r, neg, best)) != 0)
! return res;
if (! (sub_req = best->sub_req)) {
/* We got this out of a map file, so we don't actually have
--- 1924,1937 ----
set_neg_headers (r, neg, na_result);
store_variant_list (r, neg);
! res = NOT_ACCEPTABLE;
! goto return_from_multi;
}
if (na_result == na_choice)
! if ((res = setup_choice_response(r, neg, best)) != 0) {
! goto return_from_multi;
! }
if (! (sub_req = best->sub_req)) {
/* We got this out of a map file, so we don't actually have
***************
*** 1920,1931 ****
*/
sub_req = sub_req_lookup_file (best->file_name, r);
! if (sub_req->status != 200) return sub_req->status;
}
/* BLETCH --- don't multi-resolve non-ordinary files */
! if (!S_ISREG(sub_req->finfo.st_mode)) return NOT_FOUND;
/* Otherwise, use it. */
--- 1939,1956 ----
*/
sub_req = sub_req_lookup_file (best->file_name, r);
! if (sub_req->status != HTTP_OK) {
! res = sub_req->status;
! goto return_from_multi;
! }
}
/* BLETCH --- don't multi-resolve non-ordinary files */
! if (!S_ISREG(sub_req->finfo.st_mode)) {
! res = NOT_FOUND;
! goto return_from_multi;
! }
/* Otherwise, use it. */
***************
*** 1942,1948 ****
r->content_languages = sub_req->content_languages;
r->content_language = sub_req->content_language;
r->finfo = sub_req->finfo;
!
return OK;
}
--- 1967,1983 ----
r->content_languages = sub_req->content_languages;
r->content_language = sub_req->content_language;
r->finfo = sub_req->finfo;
! /* copy output headers from subrequest, but leave negotiation headers */
! overlay_tables(r->pool, sub_req->notes, r->notes);
! overlay_tables(r->pool, sub_req->headers_out, r->headers_out);
! overlay_tables(r->pool, sub_req->err_headers_out, r->err_headers_out);
! avail_recs = (var_rec *)neg->avail_vars->elts;
! for (j = 0; j < neg->avail_vars->nelts; ++j) {
! var_rec *variant = &avail_recs[j];
! if (variant != best && variant->sub_req) {
! destroy_sub_req(variant->sub_req);
! }
! }
return OK;
}