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 1998/09/24 23:58:09 UTC

[PATCH] for error-notes and ap_send_error_response() (#2)

This patch is essentially the same as the first, except that
the in-core (in-http_protocol, actually) uses of error-notes
are explicitly included in the error page content-body.

#ken    P-)}

Ken Coar                    <http://Web.Golux.Com/coar/>
Apache Group member         <http://www.apache.org/>
"Apache Server for Dummies" <http://Web.Golux.Com/coar/ASFD/>

Index: main/http_log.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_log.c,v
retrieving revision 1.69
diff -u -r1.69 http_log.c
--- http_log.c  1998/09/22 15:43:42     1.69
+++ http_log.c  1998/09/24 21:52:02
@@ -440,9 +440,18 @@
 
     va_start(args, fmt);
     log_error_core(file, line, level, r->server, r, fmt, args);
-    if (ap_table_get(r->notes, "error-notes") == NULL) {
+    /*
+     * IF the error level is 'warning' or more severe,
+     * AND there isn't already error text associated with this
request,
+     * THEN make the message text available to ErrorDocument and
+     * other error processors.  This can be disabled by stuffing
+     * something, even an empty string, into the "error-notes"
cell
+     * before calling this routine.
+     */
+    if (((level & APLOG_LEVELMASK) <= APLOG_WARNING)
+       && (ap_table_get(r->notes, "error-notes") == NULL)) {
        ap_table_setn(r->notes, "error-notes",
-           ap_pvsprintf(r->pool, fmt, args));
+                     ap_pvsprintf(r->pool, fmt, args));
     }
     va_end(args);
 }
Index: main/http_protocol.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_protocol.c,v
retrieving revision 1.239
diff -u -r1.239 http_protocol.c
--- http_protocol.c     1998/08/25 09:15:31     1.239
+++ http_protocol.c     1998/09/24 21:52:07
@@ -2127,132 +2127,141 @@
                   "</TITLE>\n</HEAD><BODY>\n<H1>", h1,
"</H1>\n",
                   NULL);
 
-        if ((error_notes = ap_table_get(r->notes,
"error-notes"))) {
-            ap_bputs(error_notes, fd);
-        }
-        else
-            switch (status) {
-            case REDIRECT:
-            case MOVED:
-                ap_bvputs(fd, "The document has moved <A
HREF=\"",
-                          ap_escape_html(r->pool, location),
"\">here</A>.<P>\n", NULL);
-                break;
-            case HTTP_SEE_OTHER:
-                ap_bvputs(fd, "The answer to your request is
located <A HREF=\"",
-                          ap_escape_html(r->pool, location),
"\">here</A>.<P>\n", NULL);
-                break;
-            case HTTP_USE_PROXY:
-                ap_bvputs(fd, "This resource is only accessible
through the proxy\n",
-                ap_escape_html(r->pool, location), "<BR>\nYou
will need to ",
-                     "configure your client to use that
proxy.<P>\n", NULL);
-                break;
-            case HTTP_PROXY_AUTHENTICATION_REQUIRED:
-            case AUTH_REQUIRED:
-                ap_bputs("This server could not verify that
you\n", fd);
-                ap_bputs("are authorized to access the document
you\n", fd);
-                ap_bputs("requested.  Either you supplied the
wrong\n", fd);
-                ap_bputs("credentials (e.g., bad password), or
your\n", fd);
-                ap_bputs("browser doesn't understand how to
supply\n", fd);
-                ap_bputs("the credentials required.<P>\n", fd);
-                break;
-            case BAD_REQUEST:
-                ap_bputs("Your browser sent a request that\n",
fd);
-                ap_bputs("this server could not
understand.<P>\n", fd);
-                break;
-            case HTTP_FORBIDDEN:
-                ap_bvputs(fd, "You don't have permission to
access ",
-                  ap_escape_html(r->pool, r->uri), "\non this
server.<P>\n",
-                          NULL);
-                break;
-            case NOT_FOUND:
-                ap_bvputs(fd, "The requested URL ",
ap_escape_html(r->pool, r->uri),
-                          " was not found on this server.<P>\n",
NULL);
-                break;
-            case METHOD_NOT_ALLOWED:
-                ap_bvputs(fd, "The requested method ",
r->method, " is not allowed "
-                          "for the URL ",
ap_escape_html(r->pool, r->uri),
-                          ".<P>\n", NULL);
-                break;
-            case NOT_ACCEPTABLE:
-                ap_bvputs(fd,
-                 "An appropriate representation of the requested
resource ",
-                          ap_escape_html(r->pool, r->uri),
-                          " could not be found on this
server.<P>\n", NULL);
-                /* fall through */
-            case MULTIPLE_CHOICES:
-                {
-                    const char *list;
-                    if ((list = ap_table_get(r->notes,
"variant-list")))
-                        ap_bputs(list, fd);
-                }
-                break;
-            case LENGTH_REQUIRED:
-                ap_bvputs(fd, "A request of the requested method
", r->method,
-                          " requires a valid
Content-length.<P>\n", NULL);
-                break;
-            case PRECONDITION_FAILED:
-                ap_bvputs(fd, "The precondition on the request
for the URL ",
-                ap_escape_html(r->pool, r->uri), " evaluated to
false.<P>\n",
-                          NULL);
-                break;
-            case NOT_IMPLEMENTED:
-                ap_bvputs(fd, ap_escape_html(r->pool,
r->method), " to ",
-                          ap_escape_html(r->pool, r->uri), " not
supported.<P>\n", NULL);
-                break;
-            case BAD_GATEWAY:
-                ap_bputs("The proxy server received an
invalid\015\012", fd);
-                ap_bputs("response from an upstream
server.<P>\015\012", fd);
-                break;
-            case VARIANT_ALSO_VARIES:
-                ap_bvputs(fd, "A variant for the requested
entity  ",
-                          ap_escape_html(r->pool, r->uri), " is
itself a ",
-                          "transparently negotiable
resource.<P>\n", NULL);
-                break;
-            case HTTP_REQUEST_TIME_OUT:
-                ap_bputs("I'm tired of waiting for your
request.\n", fd);
-                break;
-            case HTTP_GONE:
-                ap_bvputs(fd, "The requested resource<BR>",
-                          ap_escape_html(r->pool, r->uri),
-                          "<BR>\nis no longer available on this
server ",
-                          "and there is no forwarding
address.\n",
-                  "Please remove all references to this
resource.\n", NULL);
-                break;
-            case HTTP_REQUEST_ENTITY_TOO_LARGE:
-                ap_bvputs(fd, "The requested resource<BR>",
-                          ap_escape_html(r->pool, r->uri),
"<BR>\n",
-                          "does not allow request data with ",
r->method,
-                          " requests, or the amount of data
provided in\n",
-                          "the request exceeds the capacity
limit.\n", NULL);
-                break;
-            case HTTP_REQUEST_URI_TOO_LARGE:
-                ap_bputs("The requested URL's length exceeds the
capacity\n", fd);
-                ap_bputs("limit for this server.\n", fd);
-                break;
-            case HTTP_UNSUPPORTED_MEDIA_TYPE:
-                ap_bputs("The supplied request data is not in a
format\n", fd);
-                ap_bputs("acceptable for processing by this
resource.\n", fd);
-                break;
-            case HTTP_SERVICE_UNAVAILABLE:
-                ap_bputs("The server is temporarily unable to
service your\n", fd);
-                ap_bputs("request due to maintenance downtime or
capacity\n", fd);
-                ap_bputs("problems. Please try again later.\n",
fd);
-                break;
-            case HTTP_GATEWAY_TIME_OUT:
-                ap_bputs("The proxy server did not receive a
timely response\n", fd);
-                ap_bputs("from the upstream server.<P>\n", fd);
-                break;
-            default:            /* HTTP_INTERNAL_SERVER_ERROR */
-                ap_bputs("The server encountered an internal
error or\n", fd);
-                ap_bputs("misconfiguration and was unable to
complete\n", fd);
-                ap_bputs("your request.<P>\n", fd);
-                ap_bputs("Please contact the server
administrator,\n ", fd);
-                ap_bputs(ap_escape_html(r->pool,
r->server->server_admin), fd);
-                ap_bputs(" and inform them of the time the error
occurred,\n", fd);
-                ap_bputs("and anything you might have done that
may have\n", fd);
-                ap_bputs("caused the error.<P>\n", fd);
-                break;
-            }
+       switch (status) {
+       case REDIRECT:
+       case MOVED:
+           ap_bvputs(fd, "The document has moved <A HREF=\"",
+                     ap_escape_html(r->pool, location),
"\">here</A>.<P>\n",
+                     NULL);
+           break;
+       case HTTP_SEE_OTHER:
+           ap_bvputs(fd, "The answer to your request is located
<A HREF=\"",
+                     ap_escape_html(r->pool, location),
"\">here</A>.<P>\n",
+                     NULL);
+           break;
+       case HTTP_USE_PROXY:
+           ap_bvputs(fd, "This resource is only accessible "
+                     "through the proxy\n",
+                     ap_escape_html(r->pool, location),
+                     "<BR>\nYou will need to ",
+                     "configure your client to use that
proxy.<P>\n", NULL);
+           break;
+       case HTTP_PROXY_AUTHENTICATION_REQUIRED:
+       case AUTH_REQUIRED:
+           ap_bputs("This server could not verify that you\n",
fd);
+           ap_bputs("are authorized to access the document
you\n", fd);
+           ap_bputs("requested.  Either you supplied the
wrong\n", fd);
+           ap_bputs("credentials (e.g., bad password), or
your\n", fd);
+           ap_bputs("browser doesn't understand how to
supply\n", fd);
+           ap_bputs("the credentials required.<P>\n", fd);
+           break;
+       case BAD_REQUEST:
+           ap_bputs("Your browser sent a request that\n", fd);
+           ap_bputs("this server could not understand.<P>\n",
fd);
+           if (error_notes = ap_table_get(r->notes,
"error-notes") != NULL) {
+               ap_bvputs(fd, error_notes, "<P>\n", NULL);
+           }
+           break;
+       case HTTP_FORBIDDEN:
+           ap_bvputs(fd, "You don't have permission to access ",
+                     ap_escape_html(r->pool, r->uri),
+                     "\non this server.<P>\n", NULL);
+           break;
+       case NOT_FOUND:
+           ap_bvputs(fd, "The requested URL ",
+                     ap_escape_html(r->pool, r->uri),
+                     " was not found on this server.<P>\n",
NULL);
+           break;
+       case METHOD_NOT_ALLOWED:
+           ap_bvputs(fd, "The requested method ", r->method,
+                     " is not allowed "
+                     "for the URL ", ap_escape_html(r->pool,
r->uri),
+                     ".<P>\n", NULL);
+           break;
+       case NOT_ACCEPTABLE:
+           ap_bvputs(fd,
+                     "An appropriate representation of the "
+                     "requested resource ",
+                     ap_escape_html(r->pool, r->uri),
+                     " could not be found on this server.<P>\n",
NULL);
+           /* fall through */
+       case MULTIPLE_CHOICES:
+           {
+               const char *list;
+               if ((list = ap_table_get(r->notes,
"variant-list")))
+                   ap_bputs(list, fd);
+           }
+           break;
+       case LENGTH_REQUIRED:
+           ap_bvputs(fd, "A request of the requested method ",
r->method,
+                     " requires a valid Content-length.<P>\n",
NULL);
+           break;
+       case PRECONDITION_FAILED:
+           ap_bvputs(fd, "The precondition on the request for
the URL ",
+                     ap_escape_html(r->pool, r->uri),
+                     " evaluated to false.<P>\n", NULL);
+           break;
+       case NOT_IMPLEMENTED:
+           ap_bvputs(fd, ap_escape_html(r->pool, r->method), "
to ",
+                     ap_escape_html(r->pool, r->uri),
+                     " not supported.<P>\n", NULL);
+           break;
+       case BAD_GATEWAY:
+           ap_bputs("The proxy server received an
invalid\015\012", fd);
+           ap_bputs("response from an upstream
server.<P>\015\012", fd);
+           break;
+       case VARIANT_ALSO_VARIES:
+           ap_bvputs(fd, "A variant for the requested entity  ",
+                     ap_escape_html(r->pool, r->uri), " is
itself a ",
+                     "transparently negotiable resource.<P>\n",
NULL);
+           break;
+       case HTTP_REQUEST_TIME_OUT:
+           ap_bputs("I'm tired of waiting for your request.\n",
fd);
+           break;
+       case HTTP_GONE:
+           ap_bvputs(fd, "The requested resource<BR>",
+                     ap_escape_html(r->pool, r->uri),
+                     "<BR>\nis no longer available on this
server ",
+                     "and there is no forwarding address.\n",
+                     "Please remove all references to this
resource.\n",
+                     NULL);
+           break;
+       case HTTP_REQUEST_ENTITY_TOO_LARGE:
+           ap_bvputs(fd, "The requested resource<BR>",
+                     ap_escape_html(r->pool, r->uri), "<BR>\n",
+                     "does not allow request data with ",
r->method,
+                     " requests, or the amount of data provided
in\n",
+                     "the request exceeds the capacity
limit.\n", NULL);
+           break;
+       case HTTP_REQUEST_URI_TOO_LARGE:
+           ap_bputs("The requested URL's length exceeds the
capacity\n", fd);
+           ap_bputs("limit for this server.\n", fd);
+           break;
+       case HTTP_UNSUPPORTED_MEDIA_TYPE:
+           ap_bputs("The supplied request data is not in a
format\n", fd);
+           ap_bputs("acceptable for processing by this
resource.\n", fd);
+           break;
+       case HTTP_SERVICE_UNAVAILABLE:
+           ap_bputs("The server is temporarily unable to service
your\n", fd);
+           ap_bputs("request due to maintenance downtime or
capacity\n", fd);
+           ap_bputs("problems. Please try again later.\n", fd);
+           break;
+       case HTTP_GATEWAY_TIME_OUT:
+           ap_bputs("The proxy server did not receive a timely
response\n",
+                    fd);
+           ap_bputs("from the upstream server.<P>\n", fd);
+           break;
+       default:            /* HTTP_INTERNAL_SERVER_ERROR */
+           ap_bputs("The server encountered an internal error
or\n", fd);
+           ap_bputs("misconfiguration and was unable to
complete\n", fd);
+           ap_bputs("your request.<P>\n", fd);
+           ap_bputs("Please contact the server administrator,\n
", fd);
+           ap_bputs(ap_escape_html(r->pool,
r->server->server_admin), fd);
+           ap_bputs(" and inform them of the time the error
occurred,\n", fd);
+           ap_bputs("and anything you might have done that may
have\n", fd);
+           ap_bputs("caused the error.<P>\n", fd);
+           break;
+       }
 
         if (recursive_error) {
             ap_bvputs(fd, "<P>Additionally, a ",