From: Eric Covener Date: Thu, 8 Sep 2011 15:59:38 +0000 (+0000) Subject: Merge r1166663, r1166667 from trunk: X-Git-Tag: 2.2.21~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b89047d79984bf21f748d404b10ab6066dbc7f88;p=thirdparty%2Fapache%2Fhttpd.git Merge r1166663, r1166667 from trunk: refactor to pull setting of Accept-Ranges header into http_protocol.c which had been copied to other handlers. Set Accept-Rangs: none instead of unsetting the Accept-Range header when we have a filter that doesn't like byteranges. Submitted By: Eric Covener Reviewed By: covener, wrowe, rpluem git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@1166772 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 0f944900697..07fd378a8d3 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes with Apache 2.2.21 + *) mod_filter: Instead of dropping the Accept-Ranges header when a filter + registered with AP_FILTER_PROTO_NO_BYTERANGE is present, + set the header value to "none". [Eric Covener, Ruediger Pluem] + *) mod_proxy_ajp: Ignore flushing if headers have not been sent. PR 51608 [Ruediger Pluem] @@ -18,8 +22,8 @@ Changes with Apache 2.2.21 referencing the invalid int: map at runtime. PR 50994. [Ben Noordhuis ] - *) core: Add MaxRanges directive to control the number of ranges permitted - before returning the entire resource, with a default limit of 200. + *) core: Allow MaxRanges none|unlimited|default and set 'Accept-Ranges: none' + in the case Ranges are being ignored with MaxRanges none. [Eric Covener] *) mod_proxy_ajp: Respect "reuse" flag in END_REPONSE packets. diff --git a/STATUS b/STATUS index 3d8002f5aa6..0ea546884a5 100644 --- a/STATUS +++ b/STATUS @@ -93,17 +93,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * core: Send Accept-Ranges: none when MaxRanges none is configured - Trunk version of patch: - http://svn.apache.org/viewvc?rev=1166282&view=rev (Just the Accept-Range change) - revised 9/8: add http://svn.apache.org/viewvc?rev=1166663&view=rev - add http://svn.apache.org/viewvc?rev=1166667&view=rev - - 2.2.x version of patch: - http://people.apache.org/~covener/patches/httpd-2.2.x-maxranges-norange.diff - w/ 9/8 additions: http://people.apache.org/~covener/patches/httpd-2.2.x-accept_ranges_none.diff - +1: covener, wrowe, rpluem - * mod_proxy_ajp: return HTTP_NOT_IMPLEMENTED when AJP_EBAD_METHOD Trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1166551 & http://svn.apache.org/viewvc?view=revision&revision=1166657 diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 50fe52cfcbf..bee9853a4a5 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -147,6 +147,7 @@ * 20051115.28 (2.2.19) Restore ap_unescape_url_keep2f(char *url) signature * altered in 2.2.18. Add ap_unescape_url_keep2f_ex(). * 20051115.29 (2.2.21) add max_ranges to core_dir_config + * 20051115.30 (2.2.21) add ap_set_accept_ranges() */ #define MODULE_MAGIC_COOKIE 0x41503232UL /* "AP22" */ @@ -154,7 +155,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20051115 #endif -#define MODULE_MAGIC_NUMBER_MINOR 29 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 30 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/include/http_protocol.h b/include/http_protocol.h index 276d09bf98f..d18f1ed2298 100644 --- a/include/http_protocol.h +++ b/include/http_protocol.h @@ -309,6 +309,13 @@ AP_DECLARE(void) ap_clear_method_list(ap_method_list_t *l); */ AP_DECLARE(void) ap_set_content_type(request_rec *r, const char *ct); +/** + * Set the Accept-Ranges header for this response + * @param r The current request + */ +AP_DECLARE(void) ap_set_accept_ranges(request_rec *r); + + /* Hmmm... could macrofy these for now, and maybe forever, though the * definitions of the macros would get a whole lot hairier. */ diff --git a/modules/dav/fs/repos.c b/modules/dav/fs/repos.c index bb1978815b0..0502808c652 100644 --- a/modules/dav/fs/repos.c +++ b/modules/dav/fs/repos.c @@ -948,7 +948,7 @@ static dav_error * dav_fs_set_headers(request_rec *r, ap_set_etag(r); /* we accept byte-ranges */ - apr_table_setn(r->headers_out, "Accept-Ranges", "bytes"); + ap_set_accept_ranges(r); /* set up the Content-Length header */ ap_set_content_length(r, resource->info->finfo.size); diff --git a/modules/filters/mod_filter.c b/modules/filters/mod_filter.c index 8e706229352..ad7aba3daa6 100644 --- a/modules/filters/mod_filter.c +++ b/modules/filters/mod_filter.c @@ -321,7 +321,7 @@ static int filter_lookup(ap_filter_t *f, ap_filter_rec_t *filter) } if (proto_flags & AP_FILTER_PROTO_NO_BYTERANGE) { - apr_table_unset(r->headers_out, "Accept-Ranges"); + apr_table_setn(r->headers_out, "Accept-Ranges", "none"); } else if (rctx && rctx->range) { /* restore range header we saved earlier */ diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index be864e8256e..6812c490490 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -848,6 +848,13 @@ AP_DECLARE(void) ap_set_content_type(request_rec *r, const char *ct) } } +AP_DECLARE(void) ap_set_accept_ranges(request_rec *r) +{ + core_dir_config *d = ap_get_module_config(r->per_dir_config, &core_module); + apr_table_setn(r->headers_out, "Accept-Ranges", + (d->max_ranges == AP_MAXRANGES_NORANGES) ? "none" + : "bytes"); +} static const char *add_optional_notes(request_rec *r, const char *prefix, const char *key, diff --git a/modules/mappers/mod_negotiation.c b/modules/mappers/mod_negotiation.c index 6feb58c0a56..25e60348b77 100644 --- a/modules/mappers/mod_negotiation.c +++ b/modules/mappers/mod_negotiation.c @@ -3009,7 +3009,7 @@ static int handle_map_file(request_rec *r) * ap_set_last_modified(r); * ap_set_etag(r); */ - apr_table_setn(r->headers_out, "Accept-Ranges", "bytes"); + ap_set_accept_ranges(r); ap_set_content_length(r, best->bytes); /* set MIME type and charset as negotiated */ diff --git a/server/core.c b/server/core.c index f2cfd48ebcd..ca72713925f 100644 --- a/server/core.c +++ b/server/core.c @@ -3763,7 +3763,7 @@ static int default_handler(request_rec *r) ap_update_mtime(r, r->finfo.mtime); ap_set_last_modified(r); ap_set_etag(r); - apr_table_setn(r->headers_out, "Accept-Ranges", "bytes"); + ap_set_accept_ranges(r); ap_set_content_length(r, r->finfo.size); bb = apr_brigade_create(r->pool, c->bucket_alloc);