]> granicus.if.org Git - apache/commitdiff
This test for TraceEnable cases cannot be buried within the max-forwards
authorWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 6 Jul 2005 04:10:50 +0000 (04:10 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 6 Jul 2005 04:10:50 +0000 (04:10 +0000)
  logic cases.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@209406 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy.c

index 4ac61ccc816899842c915f12259698555bad89f9..5b120fd9586aaa1134d1e4e206c5673bfb5628ec 100644 (file)
@@ -541,23 +541,7 @@ static int proxy_handler(request_rec *r)
         if (maxfwd < 1) {
             switch (r->method_number) {
             case M_TRACE: {
-                core_server_config *coreconf = (core_server_config *)
-                                    ap_get_module_config(sconf, &core_module);
                 int access_status;
-
-                if (coreconf->trace_enable == AP_TRACE_DISABLE)
-                    return ap_proxyerror(r, HTTP_NOT_IMPLEMENTED,
-                                         "TRACE denied by server configuration");
-
-                /* Can't test ap_should_client_block, we aren't ready to send
-                 * the client a 100 Continue response till the connection has
-                 * been established
-                 */
-                if (coreconf->trace_enable != AP_TRACE_EXTENDED 
-                    && (r->read_length || (!r->read_chunked && (r->remaining <= 0))))
-                    return ap_proxyerror(r, HTTP_REQUEST_ENTITY_TOO_LARGE,
-                                         "TRACE with request body is not allowed");
-
                 r->proxyreq = PROXYREQ_NONE;
                 if ((access_status = ap_send_http_trace(r)))
                     ap_die(access_status, r);
@@ -589,6 +573,42 @@ static int proxy_handler(request_rec *r)
     apr_table_set(r->headers_in, "Max-Forwards", 
                   apr_psprintf(r->pool, "%ld", (maxfwd > 0) ? maxfwd : 0));
 
+    if (r->method_number == M_TRACE) {
+        core_server_config *coreconf = (core_server_config *)
+                            ap_get_module_config(sconf, &core_module);
+
+        if (coreconf->trace_enable == AP_TRACE_DISABLE) 
+        {
+            /* Allow "error-notes" string to be printed by ap_send_error_response()
+             * Note; this goes nowhere, canned error response need an overhaul.
+             */
+            apr_table_setn(r->notes, "error-notes",
+                           "TRACE forbidden by server configuration");
+            apr_table_setn(r->notes, "verbose-error-to", "*");
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                          "proxy: TRACE forbidden by server configuration");
+            return HTTP_FORBIDDEN;
+        }
+
+        /* Can't test ap_should_client_block, we aren't ready to send
+         * the client a 100 Continue response till the connection has
+         * been established
+         */
+        if (coreconf->trace_enable != AP_TRACE_EXTENDED 
+            && (r->read_length || r->read_chunked || r->remaining))
+        {
+            /* Allow "error-notes" string to be printed by ap_send_error_response()
+             * Note; this goes nowhere, canned error response need an overhaul.
+             */
+            apr_table_setn(r->notes, "error-notes",
+                           "TRACE with request body is not allowed");
+            apr_table_setn(r->notes, "verbose-error-to", "*");
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                          "proxy: TRACE with request body is not allowed");
+            return HTTP_REQUEST_ENTITY_TOO_LARGE;
+        }
+    }
+
     uri = r->filename + 6;
     p = strchr(uri, ':');
     if (p == NULL) {