You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Cliff Skolnick <cl...@steam.com> on 1999/01/25 19:59:35 UTC

[PATCH] 500 errors not giving error-notes (related to PR #3455)

Here's a patch to allow apache acting as a proxy server to relay the real
reason of a failure to a client rather than the "internal server error" it
does currently.  I started to add a "ExposeErrors to" directive which would
expose more than just proxy errors to a list of IP's, but it did not seems
like a good idea after thinking about it.  If pestered I'll finish coding
and testing that mechanism.

This is a bit more of a general solution than the patch included in PR
#3455, since any module who wished to expose error-notes to all clients can
set "verbose-errors-to" to "*" at the time of setting "error-notes" rather
than changing the error status.

Cliff


Index: src/main/http_protocol.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/main/http_protocol.c,v
retrieving revision 1.253
diff -u -r1.253 http_protocol.c
--- http_protocol.c	1999/01/08 17:54:41	1.253
+++ http_protocol.c	1999/01/25 10:01:37
@@ -2498,7 +2498,19 @@
                      "accepted by the server for this resource.\n", fd);
 	    break;
 	default:            /* HTTP_INTERNAL_SERVER_ERROR */
-	    ap_bvputs(fd, "The server encountered an internal error or\n"
+	    /*
+	     * This comparison to expose error-notes could be modified to
+	     * use a configuration directive and export based on that 
+	     * directive.  For now "*" is used to designate an error-notes
+	     * that is totally safe for any user to see (ie lacks paths,
+	     * database passwords, etc.)
+	     */
+	    if (((error_notes = ap_table_get(r->notes, "error-notes")) != NULL)
+		&& (strncmp(ap_table_get(r->notes, "verbose-error-to"), "*", 1)
+		    == 0)) {
+	        ap_bvputs(fd, error_notes, "<P>\n", NULL);
+	    } else {
+	        ap_bvputs(fd, "The server encountered an internal error or\n"
 	             "misconfiguration and was unable to complete\n"
 	             "your request.<P>\n"
 	             "Please contact the server administrator,\n ",
@@ -2508,6 +2520,7 @@
 	             "caused the error.<P>\n"
 		     "More information about this error may be available\n"
 		     "in the server error log.<P>\n", NULL);
+	    }
 	 /*
 	  * It would be nice to give the user the information they need to
 	  * fix the problem directly since many users don't have access to
Index: src/modules/proxy/proxy_util.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/modules/proxy/proxy_util.c,v
retrieving revision 1.74
diff -u -r1.74 proxy_util.c
--- proxy_util.c	1999/01/01 19:05:03	1.74
+++ proxy_util.c	1999/01/25 10:02:07
@@ -842,6 +842,7 @@
 			     "<EM><A HREF=\"", r->uri, "\">",
 			     r->method, "&nbsp;", r->uri, "</A></EM>.<P>\n"
 			     "Reason: <STRONG>", message, "</STRONG>", NULL));
+    ap_table_setn(r->notes, "verbose-error-to", ap_pstrcat(r->pool, "*"));
     r->status_line = "500 Proxy Error";
     return HTTP_INTERNAL_SERVER_ERROR;
 }

--
Cliff Skolnick
Steam Tunnel Operations
cliff@steam.com
http://www.steam.com/




Re: [PATCH] 500 errors not giving error-notes (related to PR #3455)

Posted by Martin Kraemer <ma...@mch.sni.de>.
On Mon, Jan 25, 1999 at 10:59:35AM -0800, Cliff Skolnick wrote:
> +++ http_protocol.c	1999/01/25 10:01:37
> +	    if (((error_notes = ap_table_get(r->notes, "error-notes")) != NULL)
> +		&& (strncmp(ap_table_get(r->notes, "verbose-error-to"), "*", 1)

Why not strcmp()? If the asterisk is the only thing that is checked for
general applicability of the error-notes string, then strcmp() would be
sufficient.

> +++ proxy_util.c	1999/01/25 10:02:07
> @@ -842,6 +842,7 @@
>  			     "<EM><A HREF=\"", r->uri, "\">",
>  			     r->method, "&nbsp;", r->uri, "</A></EM>.<P>\n"
>  			     "Reason: <STRONG>", message, "</STRONG>", NULL));
> +    ap_table_setn(r->notes, "verbose-error-to", ap_pstrcat(r->pool, "*"));
						   ^^^^^^^^^^^^^^^^^^^^^^^
This probably was meant to read ap_pstrdup()...

Good idea. +1 with the strdup() modification above.

    Martin
-- 
<Ma...@MchP.Siemens.De>      |        Siemens Information and
Phone: +49-89-636-46021               |        Communication  Products
FAX:   +49-89-636-47816               |        81730  Munich,  Germany

Re: [PATCH] 500 errors not giving error-notes (related to PR #3455)

Posted by Dirk-Willem van Gulik <di...@jrc.it>.
Cliff Skolnick wrote:
 
> Here's a patch to allow apache acting as a proxy server to relay the real
> reason of a failure to a client rather than the "internal server error" it
> does currently.  I started to add a "ExposeErrors to" directive which would
> expose more than just proxy errors to a list of IP's, but it did not seems
> like a good idea after thinking about it.  If pestered I'll finish coding
> and testing that mechanism.

Happy to see this approach. I have to admit that this worried me quite a bit; 
as basically proxies are rougly used in two ways; as part of a mirror/cache or
some tunnel procedure to give inside people access to the outside; in which 
case relaying errors is no problems; or for quite the reverse; shielding what
goes on inside from the outside. And then this 'ExposeErrors' control is vital.

Dw