From 179ca062fd3e022ea357e496fe5a85d5a244f0f3 Mon Sep 17 00:00:00 2001 From: "William A. Rowe Jr" Date: Wed, 6 Jul 2005 04:10:50 +0000 Subject: [PATCH] This test for TraceEnable cases cannot be buried within the max-forwards 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 | 52 +++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index 4ac61ccc81..5b120fd958 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -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) { -- 2.40.0