You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Will Lowe <ha...@thebackrow.net> on 2004/02/25 22:57:45 UTC
1.x: byte-range with ErrorDocuments returns incorrect status code
It looks like byte-range requests on non-existant files returns 206
instead of 404 if ErrorDocument is set. This Debian's testing and
stable releases, running on sparc and i386 respectively. I have this
in my config on my 1.x server:
Alias /errordocs/404.html /etc/apache/404.html
ErrorDocument 404 /errordocs/404.html
Normal requests work as expected:
harpo@alley:~$ curl -si http://leftcoast.thebackrow.net/nosuchfile.txt
HTTP/1.1 404 Not Found
... followed by the error document I configured. But byte-range
requests return 206 instead of 404:
harpo@alley:~$ curl -r 10-20 -si http://leftcoast.thebackrow.net/nosuchfile.txt
HTTP/1.1 206 Partial Content
And it returns me bytes 10-20 of the ErrorDocument. It looks to me
like this is because r->status gets overwritten to 206 by
ap_set_byterange() in the subrequest.
Here are a coupla thoughts I had on possible fixes (I need this badly
enough that I will code and test a fix if necessary):
* remove the Range: header from the subrequest inside ap_die(),
thereby making this NOT a byte-range request anymore.
* have ap_set_byterange() only set r->status if r->status isn't set
(how do we determine "isn't set"?)
* have ap_set_byterange() only set r->status if r->status isn't set
to a 2xx or 3xx code already
Any thoughts?
--
thanks,
Will
Re: 1.x: byte-range with ErrorDocuments returns incorrect status
code
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
Will Lowe wrote:
> Thanks for the quick response -- sorry I've been slow getting back to
> you. Yes, the attached patch does seem to fix 1.3.X. It'd be great if
> it got rolled into the next point release.
ok, I'll try and guide it through the process.
--Geoff
Re: 1.x: byte-range with ErrorDocuments returns incorrect status code
Posted by Will Lowe <ha...@thebackrow.net>.
Thanks for the quick response -- sorry I've been slow getting back to
you. Yes, the attached patch does seem to fix 1.3.X. It'd be great if
it got rolled into the next point release.
On Thu, Feb 26, 2004 at 09:18:02AM -0500, Geoffrey Young wrote:
>
>
> Will Lowe wrote:
> > It looks like byte-range requests on non-existant files returns 206
> > instead of 404 if ErrorDocument is set.
>
> I was able to verify this - it looks like there's some simple logic in 2.0
> that wasn't carried over to 1.3.
>
> so, try this patch. all the byterange tests in the perl-framework pass with
> it, in addition to my own ErrorDocument tests that I used to reproduce the
> problem.
>
> if anyone on 1.3 support is paying attention, what's the proper course for
> insertion into the stable tree once things are verified - add to STATUS and
> wait for reviews/votes?
>
> --Geoff
> Index: src/main/http_protocol.c
> ===================================================================
> RCS file: /home/cvspublic/apache-1.3/src/main/http_protocol.c,v
> retrieving revision 1.332
> diff -u -r1.332 http_protocol.c
> --- src/main/http_protocol.c 16 Feb 2004 22:29:33 -0000 1.332
> +++ src/main/http_protocol.c 26 Feb 2004 14:14:21 -0000
> @@ -260,7 +260,7 @@
> if (!(range = ap_table_get(r->headers_in, "Range")))
> range = ap_table_get(r->headers_in, "Request-Range");
>
> - if (!range || strncasecmp(range, "bytes=", 6)) {
> + if (!range || strncasecmp(range, "bytes=", 6) || r->status != HTTP_OK) {
> return 0;
> }
> range += 6;
--
thanks,
Will
Re: 1.x: byte-range with ErrorDocuments returns incorrect status
code
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
Will Lowe wrote:
> It looks like byte-range requests on non-existant files returns 206
> instead of 404 if ErrorDocument is set.
I was able to verify this - it looks like there's some simple logic in 2.0
that wasn't carried over to 1.3.
so, try this patch. all the byterange tests in the perl-framework pass with
it, in addition to my own ErrorDocument tests that I used to reproduce the
problem.
if anyone on 1.3 support is paying attention, what's the proper course for
insertion into the stable tree once things are verified - add to STATUS and
wait for reviews/votes?
--Geoff