Commit f554ddf5 authored by William A. Rowe Jr's avatar William A. Rowe Jr
Browse files

  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
parent 0d594565
Loading
Loading
Loading
Loading
+36 −16
Changes for modules/proxy/mod_proxy.c: 36 added lines, 16 removed lines.
Original line number Diff line number Diff line
@@ -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) {