httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rodent of Unusual Size <Ken.C...@Golux.Com>
Subject [PATCH] Allow ErrorDocument even on HTTP syntax errors (was: Re: Bug (?) in 1.3)
Date Tue, 27 Mar 2001 17:12:19 GMT
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/>!

Mime
View raw message