You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Rodent of Unusual Size <Ke...@Golux.Com> on 2001/03/22 16:55:13 UTC
Bug (?) in 1.3
Bill has discovered an interesting problem with ErrorDocument 400
handling..
ErrorDocument 400 "string
works every time.
ErrorDocument 400 /local-URI
works for this request:
GET foo blah
but does NOT work for the following; it sends the canned response
instead:
GET /index.html HTTP/1.0
bogus header line
This is the case in 1.3.20-dev; dunno about 2.0. Bill and I are
looking at this.
--
#ken P-)}
Ken Coar <http://Golux.Com/coar/>
Apache Software Foundation <http://www.apache.org/>
"Apache Server for Dummies" <http://Apache-Server.Com/>
"Apache Server Unleashed" <http://ApacheUnleashed.Com/>
ApacheCon 2001!
Four tracks with over 70+ sessions. Free admission to exhibits
and special events - keynote presentations by John 'maddog' Hall
and David Brin. Special thanks to our Platinum Sponsors IBM and
Covalent, Gold Sponsor Thawte, and Silver Sponsor Compaq. Attend
the only Apache event designed and fully supported by the members of
the ASF. See more information and register at <http://ApacheCon.Com/>!
Re: [PATCH] Allow ErrorDocument even on HTTP syntax errors (was: Re: Bug
(?) in 1.3)
Posted by Rodent of Unusual Size <Ke...@Golux.Com>.
"Roy T. Fielding" wrote:
>
> In any case, it is not possible to send custom responses for
> every single possible error condition, so we've got better
> things to do than fix this problem in 1.3.
Then one of those better things ought to be documenting the
cases in which custom error responses will not work.
--
#ken P-)}
Ken Coar <http://Golux.Com/coar/>
Apache Software Foundation <http://www.apache.org/>
"Apache Server for Dummies" <http://Apache-Server.Com/>
"Apache Server Unleashed" <http://ApacheUnleashed.Com/>
ApacheCon 2001!
Four tracks with over 70+ sessions. Free admission to exhibits
and special events - keynote presentations by John 'maddog' Hall
and David Brin. Special thanks to our Platinum Sponsors IBM and
Covalent, Gold Sponsor Thawte, and Silver Sponsor Compaq. Attend
the only Apache event designed and fully supported by the members of
the ASF. See more information and register at <http://ApacheCon.Com/>!
Re: [PATCH] Allow ErrorDocument even on HTTP syntax errors (was: Re: Bug
(?) in 1.3)
Posted by Rodent of Unusual Size <Ke...@Golux.Com>.
"Roy T. Fielding" wrote:
>
> Nope, -1. This won't work because those are conditions tested
> before the request record contains elements needed by die and
> its subsequently called subroutines.
I *did* test these cases, you know..
> In any case, it is not possible to send custom responses for
> every single possible error condition, so we've got better
> things to do than fix this problem in 1.3.
Please do not tell me how I should be spending my time..
--
#ken P-)}
Ken Coar <http://Golux.Com/coar/>
Apache Software Foundation <http://www.apache.org/>
"Apache Server for Dummies" <http://Apache-Server.Com/>
"Apache Server Unleashed" <http://ApacheUnleashed.Com/>
ApacheCon 2001!
Four tracks with over 70+ sessions. Free admission to exhibits
and special events - keynote presentations by John 'maddog' Hall
and David Brin. Special thanks to our Platinum Sponsors IBM and
Covalent, Gold Sponsor Thawte, and Silver Sponsor Compaq. Attend
the only Apache event designed and fully supported by the members of
the ASF. See more information and register at <http://ApacheCon.Com/>!
Re: [PATCH] Allow ErrorDocument even on HTTP syntax errors (was: Re: Bug (?) in 1.3)
Posted by "Roy T. Fielding" <fi...@ebuilt.com>.
On Tue, Mar 27, 2001 at 12:12:19PM -0500, Rodent of Unusual Size wrote:
> Here is a patch that will fix this, without breaking anything
> else as far as I can tell. ErrorDocument 400 will be honoured
> regardless of the cause of the HTTP_BAD_REQUEST condition.
>
> For 1.3.next consideration.
Nope, -1. This won't work because those are conditions tested before
the request record contains elements needed by die and its subsequently
called subroutines. In any case, it is not possible to send custom
responses for every single possible error condition, so we've got better
things to do than fix this problem in 1.3.
In order to make this work [in 2.0], the error sending code should be
replaced by something that doesn't assume it is coming at the end
of a normal request. Instead, it should be an internal redirect to
a directory of template files (301.htm, 404.htm, etc.) that can be
filtered to include the specific error information (properly encoded,
of course) based on notes given to the internal redirect. That would
separate the read-status of the initial request from the error response
handling.
....Roy
[PATCH] Allow ErrorDocument even on HTTP syntax errors (was: Re: Bug (?)
in 1.3)
Posted by Rodent of Unusual Size <Ke...@Golux.Com>.
Here is a patch that will fix this, without breaking anything
else as far as I can tell. ErrorDocument 400 will be honoured
regardless of the cause of the HTTP_BAD_REQUEST condition.
For 1.3.next consideration.
Index: src/main/http_protocol.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/main/http_protocol.c,v
retrieving revision 1.300
diff -u -r1.300 http_protocol.c
--- src/main/http_protocol.c 2001/03/09 10:10:26 1.300
+++ src/main/http_protocol.c 2001/03/27 17:07:57
@@ -1119,12 +1119,14 @@
ap_keepalive_timeout("read request line", r);
if (!read_request_line(r)) {
+ int rstatus;
+ rstatus = r->status;
ap_kill_timeout(r);
- if (r->status == HTTP_REQUEST_URI_TOO_LARGE) {
-
+ if (rstatus == HTTP_REQUEST_URI_TOO_LARGE) {
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r,
"request failed: URI too long");
- ap_send_error_response(r, 0);
+ r->status = HTTP_OK;
+ ap_die(rstatus, r);
ap_log_transaction(r);
return r;
}
@@ -1135,9 +1137,12 @@
get_mime_headers(r);
ap_kill_timeout(r);
if (r->status != HTTP_REQUEST_TIME_OUT) {
+ int rstatus;
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r,
"request failed: error reading the headers");
- ap_send_error_response(r, 0);
+ rstatus = r->status;
+ r->status = HTTP_OK;
+ ap_die(rstatus, r);
ap_log_transaction(r);
return r;
}
@@ -1146,6 +1151,7 @@
ap_kill_timeout(r);
if (r->header_only) {
+ int rstatus;
/*
* Client asked for headers only with HTTP/0.9, which doesn't send
* headers! Have to dink things just to make sure the error message
@@ -1155,8 +1161,9 @@
"client sent invalid HTTP/0.9 request: HEAD %s",
r->uri);
r->header_only = 0;
- r->status = HTTP_BAD_REQUEST;
- ap_send_error_response(r, 0);
+ rstatus = r->status;
+ r->status = HTTP_OK;
+ ap_die(rstatus, r);
ap_log_transaction(r);
return r;
}
@@ -1190,7 +1197,10 @@
"(see RFC2616 section 14.23): %s", r->uri);
}
if (r->status != HTTP_OK) {
- ap_send_error_response(r, 0);
+ int rstatus;
+ rstatus = r->status;
+ r->status = HTTP_OK;
+ ap_die(rstatus, r);
ap_log_transaction(r);
return r;
}
@@ -1213,12 +1223,13 @@
r->expecting_100 = 1;
}
else {
- r->status = HTTP_EXPECTATION_FAILED;
+ int rstatus;
+ rstatus = HTTP_EXPECTATION_FAILED;
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, r,
"client sent an unrecognized expectation value of "
"Expect: %s", expect);
- ap_send_error_response(r, 0);
- (void) ap_discard_request_body(r);
+ r->status = HTTP_OK;
+ ap_die(rstatus, r);
ap_log_transaction(r);
return r;
}
--
#ken P-)}
Ken Coar <http://Golux.Com/coar/>
Apache Software Foundation <http://www.apache.org/>
"Apache Server for Dummies" <http://Apache-Server.Com/>
"Apache Server Unleashed" <http://ApacheUnleashed.Com/>
ApacheCon 2001!
Four tracks with over 70+ sessions. Free admission to exhibits
and special events - keynote presentations by John 'maddog' Hall
and David Brin. Special thanks to our Platinum Sponsors IBM and
Covalent, Gold Sponsor Thawte, and Silver Sponsor Compaq. Attend
the only Apache event designed and fully supported by the members of
the ASF. See more information and register at <http://ApacheCon.Com/>!
Re: Bug (?) in 1.3
Posted by Rodent of Unusual Size <Ke...@Golux.Com>.
Just some notes on what I have found so far..
Rodent of Unusual Size wrote:
>
> GET foo blah
>
> but does NOT work for the following; it sends the canned response
> instead:
>
> GET /index.html HTTP/1.0
> bogus header line
It turns out that this discrepancy is due to the different
times of error-detection. The latter problem is detected
during header reading, and a condition is raised immediately
because it is a syntax error. The former is not detected
until after a lot more processing has been done because it
is a semantic error. Apache does not notice it until we are
heading into the actual request phase processing.
The nitty difference is that the former are signalled by
ap_die(), and the latter by ap_send_error_response() (which
is called by ap_die()). ErrorDocument redirects are
handled by ap_die(), and so do not work for the latter.
Fixing this does not look particularly simple. My gut feeling
is that the ErrorDocument redirection stuff belongs in
ap_send_error_response(), not ap_die(). That is something
big enough for 2.0 though, not 1.3. To fix this in 1.3
would probably involve getting things to the point that ap_die()
can be called during header parsing.
--
#ken P-)}
Ken Coar <http://Golux.Com/coar/>
Apache Software Foundation <http://www.apache.org/>
"Apache Server for Dummies" <http://Apache-Server.Com/>
"Apache Server Unleashed" <http://ApacheUnleashed.Com/>
ApacheCon 2001!
Four tracks with over 70+ sessions. Free admission to exhibits
and special events - keynote presentations by John 'maddog' Hall
and David Brin. Special thanks to our Platinum Sponsors IBM and
Covalent, Gold Sponsor Thawte, and Silver Sponsor Compaq. Attend
the only Apache event designed and fully supported by the members of
the ASF. See more information and register at <http://ApacheCon.Com/>!
Re: Bug (?) in 1.3
Posted by "William A. Rowe, Jr." <ad...@rowe-clan.net>.
From: "Rodent of Unusual Size" <Ke...@Golux.Com>
Sent: Thursday, March 22, 2001 9:55 AM
> Bill has discovered an interesting problem with ErrorDocument 400
> handling..
>
> ErrorDocument 400 "string
>
> works every time.
>
> ErrorDocument 400 /local-URI
>
> but does NOT work for the following; it sends the canned response
> instead:
>
> GET /index.html HTTP/1.0
> bogus header line
There's a PR or two on this (may have been closed for no response),
but I skimmed past knowing this sort of thing is usererror, 90% of the time :-(