From: Eric Covener Date: Thu, 8 Sep 2011 12:56:08 +0000 (+0000) Subject: refactor to pull setting of Accept-Ranges header into http_protocol.c which X-Git-Tag: 2.3.15~288 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c45e14b2464f2eadf022672fafd5632c835181ac;p=thirdparty%2Fapache%2Fhttpd.git refactor to pull setting of Accept-Ranges header into http_protocol.c which had been copied to other handlers. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1166663 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/ap_mmn.h b/include/ap_mmn.h index e37d874d683..95c0704389f 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -349,6 +349,7 @@ * 20110724.2 (2.3.15-dev) retries and retry_delay in util_ldap_state_t * 20110724.3 (2.3.15-dev) add util_varbuf.h / ap_varbuf API * 20110724.4 (2.3.15-dev) add max_ranges to core_dir_config + * 20110724.5 (2.3.15-dev) add ap_set_accept_ranges() */ #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */ @@ -356,7 +357,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20110724 #endif -#define MODULE_MAGIC_NUMBER_MINOR 4 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 5 /* 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 18171db2c7e..0227c228243 100644 --- a/include/http_protocol.h +++ b/include/http_protocol.h @@ -306,6 +306,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 respons + * @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 c63205ebd45..7a220000837 100644 --- a/modules/dav/fs/repos.c +++ b/modules/dav/fs/repos.c @@ -1056,7 +1056,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_reflector.c b/modules/filters/mod_reflector.c index f8c5147fe56..18074d1b625 100644 --- a/modules/filters/mod_reflector.c +++ b/modules/filters/mod_reflector.c @@ -87,7 +87,7 @@ static int reflector_handler(request_rec * r) ap_update_mtime(r, apr_time_now()); ap_set_last_modified(r); } - apr_table_setn(r->headers_out, "Accept-Ranges", "bytes"); + ap_set_accept_ranges(r); /* reflect the content length, if present */ if ((content_length = apr_table_get(r->headers_in, "Content-Length"))) { diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index a079e172ab6..0810efb697d 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -849,6 +849,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_core_module_config(r->per_dir_config); + 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 508d8f4ad85..fc13bcdc786 100644 --- a/modules/mappers/mod_negotiation.c +++ b/modules/mappers/mod_negotiation.c @@ -3007,7 +3007,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/modules/test/mod_dialup.c b/modules/test/mod_dialup.c index 316a81cc6c9..eec35f4a95b 100644 --- a/modules/test/mod_dialup.c +++ b/modules/test/mod_dialup.c @@ -172,7 +172,7 @@ dialup_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); status = ap_meets_conditions(r); diff --git a/server/core.c b/server/core.c index 632b15d5d95..02c69db6fca 100644 --- a/server/core.c +++ b/server/core.c @@ -4211,9 +4211,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", - (d->max_ranges == AP_MAXRANGES_NORANGES) ? "none" - : "bytes"); + ap_set_accept_ranges(r); ap_set_content_length(r, r->finfo.size); if (bld_content_md5) { apr_table_setn(r->headers_out, "Content-MD5",