]> granicus.if.org Git - apache/commitdiff
Add logic to the default_handler to enable script delivery to script
authorGreg Stein <gstein@apache.org>
Thu, 3 Oct 2002 00:16:47 +0000 (00:16 +0000)
committerGreg Stein <gstein@apache.org>
Thu, 3 Oct 2002 00:16:47 +0000 (00:16 +0000)
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

include/http_core.h
server/core.c

index 63a5cfe36e95851f0cf07cde2f42a8fade1ed1c0..0d3a6c79bb20c21c1eb59257aae9b004defff480 100644 (file)
@@ -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
index 72925533a1a57536b5810870d4c1b15df2e06401..c7b164fbc85f534b3db4583148a92e881d19ec04 100644 (file)
@@ -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);