From: William A. Rowe Jr Date: Thu, 13 Dec 2001 02:35:31 +0000 (+0000) Subject: Kill some redundancy (why test PUT when we disallow all but GET/POST?) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9a251232a17fd33ae0c2191bc3bdfc3d63b9226b;p=apache Kill some redundancy (why test PUT when we disallow all but GET/POST?) and add some thoughts. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92441 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/core.c b/server/core.c index 95132057db..d47a835f88 100644 --- a/server/core.c +++ b/server/core.c @@ -2705,10 +2705,14 @@ static int default_handler(request_rec *r) ap_allow_standard_methods(r, MERGE_ALLOW, M_GET, M_OPTIONS, M_POST, -1); + /* If filters intend to consume the request body, they must + * register an InputFilter to slurp the contents of the POST + * data from the POST input stream. It no longer exists when + * the output filters are invoked by the default handler. + */ if ((errstatus = ap_discard_request_body(r)) != OK) { return errstatus; } - if (r->method_number == M_INVALID) { ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r, "Invalid method in request %s", r->the_request); @@ -2717,25 +2721,20 @@ static int default_handler(request_rec *r) if (r->method_number == M_OPTIONS) { return ap_send_http_options(r); } - if (r->method_number == M_PUT) { + if (r->method_number != M_GET && r->method_number != M_POST) { return HTTP_METHOD_NOT_ALLOWED; } if (r->finfo.filetype == 0) { - ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r, - "File does not exist: %s", r->filename); - return HTTP_NOT_FOUND; - } - if (r->path_info && *r->path_info) { - ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r, - "File does not exist: %s", - apr_pstrcat(r->pool, r->filename, r->path_info, NULL)); - return HTTP_NOT_FOUND; + ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r, + "File does not exist: %s", r->filename); + return HTTP_NOT_FOUND; } - - if (r->method_number != M_GET && r->method_number != M_POST) { - return HTTP_METHOD_NOT_ALLOWED; + if (!r->used_path_info && r->path_info && *r->path_info) { + ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r, + "File does not exist: %s", + apr_pstrcat(r->pool, r->filename, r->path_info, NULL)); + return HTTP_NOT_FOUND; } - if ((status = apr_file_open(&fd, r->filename, APR_READ | APR_BINARY, 0, r->pool)) != APR_SUCCESS) { ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, "file permissions deny server access: %s", r->filename);