You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by co...@apache.org on 2011/09/08 12:41:15 UTC
svn commit: r1166612 - in /httpd/httpd/branches/2.2.x: STATUS
docs/manual/mod/core.xml include/http_core.h
modules/http/byterange_filter.c server/core.c
Author: covener
Date: Thu Sep 8 10:41:15 2011
New Revision: 1166612
URL: http://svn.apache.org/viewvc?rev=1166612&view=rev
Log:
backport r1166282 (minus Accept-Ranges: none change) from trunk:
take care of some MaxRanges feedback:
* allow "none" to be expressed in config
* stop accepting confusing/ambiguous "0", start accepting "unlimited".
Reviewed By: covener, wrowe, rpluem
Modified:
httpd/httpd/branches/2.2.x/STATUS
httpd/httpd/branches/2.2.x/docs/manual/mod/core.xml
httpd/httpd/branches/2.2.x/include/http_core.h
httpd/httpd/branches/2.2.x/modules/http/byterange_filter.c
httpd/httpd/branches/2.2.x/server/core.c
Modified: httpd/httpd/branches/2.2.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/STATUS?rev=1166612&r1=1166611&r2=1166612&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/STATUS (original)
+++ httpd/httpd/branches/2.2.x/STATUS Thu Sep 8 10:41:15 2011
@@ -93,16 +93,8 @@ RELEASE SHOWSTOPPERS:
PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
[ start all new proposals below, under PATCHES PROPOSED. ]
- * core: MaxRanges syntax change to allow unlimited|none|n>0 and prefix
- compile-time macro with AP_.
- Trunk version of patch:
- http://svn.apache.org/viewvc?rev=1166282&view=rev (minus Accept-Range change)
- 2.2.x verson of patch:
- http://people.apache.org/~covener/patches/httpd-2.2.x-maxranges-followon.diff
- (Accept-Range: changeset in separate proposal below)
- +1: covener, wrowe, rpluem
- PATCHES PROPOSED TO BACKPORT FROM TRUNK:
+PATCHES PROPOSED TO BACKPORT FROM TRUNK:
[ New proposals should be added at the end of the list ]
* mod_cache: Realign the cache_quick_handler() to behave identically
Modified: httpd/httpd/branches/2.2.x/docs/manual/mod/core.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/docs/manual/mod/core.xml?rev=1166612&r1=1166611&r2=1166612&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/docs/manual/mod/core.xml (original)
+++ httpd/httpd/branches/2.2.x/docs/manual/mod/core.xml Thu Sep 8 10:41:15 2011
@@ -2298,11 +2298,12 @@ connection</description>
</example>
</usage>
</directivesynopsis>
+
<directivesynopsis>
<name>MaxRanges</name>
<description>Number of ranges allowed before returning the complete
resource </description>
-<syntax>MaxRanges <var>number</var> (0 = no limit)</syntax>
+<syntax>MaxRanges default | unlimited | none | <var>number-of-ranges</var></syntax>
<default>MaxRanges 200</default>
<contextlist><context>server config</context><context>virtual host</context>
<context>directory</context>
@@ -2314,9 +2315,26 @@ resource </description>
limits the number of HTTP ranges the server is willing to
return to the client. If more ranges then permitted are requested,
the complete resource is returned instead.</p>
+
+ <dl>
+ <dt><strong>default</strong></dt>
+ <dd>Limits the number of ranges to a compile-time default of 200.</dd>
+
+ <dt><strong>none</strong></dt>
+ <dd>Range headers are ignored.</dd>
+
+ <dt><strong>unlimited</strong></dt>
+ <dd>The server does not limit the number of ranges it is
+ willing to satisfy.</dd>
+
+ <dt><var>number-of-ranges</var></dt>
+ <dd>A positive number representing the maximum number of ranges the
+ server is willing to satisfy.</dd>
+ </dl>
</usage>
</directivesynopsis>
+
<directivesynopsis>
<name>NameVirtualHost</name>
<description>Designates an IP address for name-virtual
Modified: httpd/httpd/branches/2.2.x/include/http_core.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/include/http_core.h?rev=1166612&r1=1166611&r2=1166612&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/include/http_core.h (original)
+++ httpd/httpd/branches/2.2.x/include/http_core.h Thu Sep 8 10:41:15 2011
@@ -571,7 +571,11 @@ typedef struct {
unsigned int decode_encoded_slashes : 1; /* whether to decode encoded slashes in URLs */
- /** Number of Ranges before returning HTTP_OK, 0/unlimited -1/unset. **/
+#define AP_MAXRANGES_UNSET -1
+#define AP_MAXRANGES_DEFAULT -2
+#define AP_MAXRANGES_UNLIMITED -3
+#define AP_MAXRANGES_NORANGES 0
+ /** Number of Ranges before returning HTTP_OK. **/
int max_ranges;
} core_dir_config;
Modified: httpd/httpd/branches/2.2.x/modules/http/byterange_filter.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/http/byterange_filter.c?rev=1166612&r1=1166611&r2=1166612&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/http/byterange_filter.c (original)
+++ httpd/httpd/branches/2.2.x/modules/http/byterange_filter.c Thu Sep 8 10:41:15 2011
@@ -55,8 +55,8 @@
#include <unistd.h>
#endif
-#ifndef DEFAULT_MAX_RANGES
-#define DEFAULT_MAX_RANGES 200
+#ifndef AP_DEFAULT_MAX_RANGES
+#define AP_DEFAULT_MAX_RANGES 200
#endif
static int ap_set_byterange(request_rec *r, apr_off_t clength,
@@ -186,7 +186,12 @@ typedef struct indexes_t {
static int get_max_ranges(request_rec *r) {
core_dir_config *core_conf = ap_get_module_config(r->per_dir_config,
&core_module);
- return core_conf->max_ranges == -1 ? DEFAULT_MAX_RANGES : core_conf->max_ranges;
+ if (core_conf->max_ranges >= 0 || core_conf->max_ranges == AP_MAXRANGES_UNLIMITED) {
+ return core_conf->max_ranges;
+ }
+
+ /* Any other negative val means the default */
+ return AP_DEFAULT_MAX_RANGES;
}
static apr_status_t send_416(ap_filter_t *f, apr_bucket_brigade *tmpbb)
@@ -251,7 +256,7 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_
num_ranges = ap_set_byterange(r, clength, &indexes);
/* We have nothing to do, get out of the way. */
- if (num_ranges == 0 || (max_ranges > 0 && num_ranges > max_ranges)) {
+ if (num_ranges == 0 || (max_ranges >= 0 && num_ranges > max_ranges)) {
r->status = original_status;
ap_remove_output_filter(f);
return ap_pass_brigade(f->next, bb);
Modified: httpd/httpd/branches/2.2.x/server/core.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/server/core.c?rev=1166612&r1=1166611&r2=1166612&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/server/core.c (original)
+++ httpd/httpd/branches/2.2.x/server/core.c Thu Sep 8 10:41:15 2011
@@ -166,7 +166,7 @@ static void *create_core_dir_config(apr_
conf->allow_encoded_slashes = 0;
conf->decode_encoded_slashes = 0;
- conf->max_ranges = -1;
+ conf->max_ranges = AP_MAXRANGES_UNSET;
return (void *)conf;
}
@@ -455,7 +455,7 @@ static void *merge_core_dir_configs(apr_
conf->allow_encoded_slashes = new->allow_encoded_slashes;
conf->decode_encoded_slashes = new->decode_encoded_slashes;
- conf->max_ranges = new->max_ranges != -1 ? new->max_ranges : base->max_ranges;
+ conf->max_ranges = new->max_ranges != AP_MAXRANGES_UNSET ? new->max_ranges : base->max_ranges;
return (void*)conf;
}
@@ -2985,11 +2985,26 @@ static const char *set_limit_xml_req_bod
static const char *set_max_ranges(cmd_parms *cmd, void *conf_, const char *arg)
{
core_dir_config *conf = conf_;
+ int val = 0;
- conf->max_ranges = atoi(arg);
- if (conf->max_ranges < 0)
- return "MaxRanges requires a non-negative integer (0 = unlimited)";
+ if (!strcasecmp(arg, "none")) {
+ val = AP_MAXRANGES_NORANGES;
+ }
+ else if (!strcasecmp(arg, "default")) {
+ val = AP_MAXRANGES_DEFAULT;
+ }
+ else if (!strcasecmp(arg, "unlimited")) {
+ val = AP_MAXRANGES_UNLIMITED;
+ }
+ else {
+ val = atoi(arg);
+ if (val <= 0)
+ return "MaxRanges requires 'none', 'default', 'unlimited' or "
+ "a positive integer";
+ }
+ conf->max_ranges = val;
+
return NULL;
}
AP_DECLARE(size_t) ap_get_limit_xml_body(const request_rec *r)