From: Greg Stein Date: Thu, 3 Oct 2002 00:16:47 +0000 (+0000) Subject: Add logic to the default_handler to enable script delivery to script X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d1581f561f4531d46e87bbc8fe12135991a45547;p=apache Add logic to the default_handler to enable script delivery to script processors located in the output filter stack. This is on by default, but will change "soon" to off -- the processors will then need to enable it when they are installed into the filter chain. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@97065 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/http_core.h b/include/http_core.h index 63a5cfe36e..0d3a6c79bb 100644 --- a/include/http_core.h +++ b/include/http_core.h @@ -342,6 +342,16 @@ typedef struct { * to add elements) */ void **notes; + + /* There is a script processor installed on the output filter chain, + * so it needs the default_handler to deliver a (script) file into + * the chain so it can process it. Normally, default_handler only + * serves files on a GET request (assuming the file is actual content), + * since other methods are not content-retrieval. This flag overrides + * that behavior, stating that the "content" is actually a script and + * won't actually be delivered as the response for the non-GET method. + */ + int deliver_script; } core_request_config; /* Standard entries that are guaranteed to be accessible via diff --git a/server/core.c b/server/core.c index 72925533a1..c7b164fbc8 100644 --- a/server/core.c +++ b/server/core.c @@ -3262,6 +3262,27 @@ static int default_handler(request_rec *r) return HTTP_NOT_FOUND; } + /* We understood the (non-GET) method, but it might not be legal for + this particular resource. Check to see if the 'deliver_script' + flag is set. If so, then we go ahead and deliver the file since + it isn't really content (only GET normally returns content). + + Note: based on logic further above, the only possible non-GET + method at this point is POST. In the future, we should enable + script delivery for all methods. */ + if (r->method_number != M_GET) { + core_request_config *req_cfg; + + req_cfg = ap_get_module_config(r->request_config, &core_module); + if (!req_cfg->deliver_script) { + /* The flag hasn't been set for this request. Punt. */ + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + "This resource does not accept the %s method.", + r->method); + return HTTP_METHOD_NOT_ALLOWED; + } + } + 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, @@ -4003,6 +4024,10 @@ static int core_create_req(request_rec *r) req_cfg = apr_pcalloc(r->pool, sizeof(core_request_config) + sizeof(void *) * num_request_notes); req_cfg->notes = (void **)((char *)req_cfg + sizeof(core_request_config)); + + /* ### temporarily enable script delivery as the default */ + req_cfg->deliver_script = 1; + if (r->main) { core_request_config *main_req_cfg = (core_request_config *) ap_get_module_config(r->main->request_config, &core_module);