mod_actions.c revision 78cd48acd325773619d78ac0d7263a99a8922fae
/* Copyright 1999-2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* mod_actions.c: executes scripts based on MIME type or HTTP method
*
* by Alexei Kosut; based on mod_cgi.c, mod_mime.c and mod_includes.c,
* adapted by rst from original NCSA code by Rob McCool
*
* Usage instructions:
*
*
* requested. It sends the URL and file path of the requested document using
* the standard CGI PATH_INFO and PATH_TRANSLATED environment variables.
*
*
* HTTP method "PUT". The available method names are defined in httpd.h.
* If the method is GET, the script will only be activated if the requested
* URI includes query information (stuff after a ?-mark).
*/
#include "apr_strings.h"
#define APR_WANT_STRFUNC
#include "apr_want.h"
#include "ap_config.h"
#include "httpd.h"
#include "http_config.h"
#include "http_request.h"
#include "http_core.h"
#include "http_protocol.h"
#include "http_main.h"
#include "http_log.h"
#include "util_script.h"
typedef struct {
int configured; /* True if Action or Script has been
* called at least once
*/
{
return new;
}
{
sizeof(action_dir_config));
int i;
base->action_types);
for (i = 0; i < METHODS; ++i) {
}
return new;
}
const char *option)
{
}
m->configured = 1;
return NULL;
}
{
/* ap_method_register recognizes already registered methods,
* so don't bother to check its previous existence explicitely.
*/
return "TRACE not allowed for Script";
}
"' for Script", NULL);
}
m->configured = 1;
return NULL;
}
static const command_rec action_cmds[] =
{
"a media type followed by a script name"),
"a method followed by a script name"),
{NULL}
};
static int action_handler(request_rec *r)
{
const char *t, *action;
const char *script;
int i;
if (!conf->configured) {
return DECLINED;
}
/* Note that this handler handles _all_ types, so handler is unchecked */
/* Set allowed stuff */
for (i = 0; i < METHODS; ++i) {
r->allowed |= (AP_METHOD_BIT << i);
}
/* First, check for the method-handling scripts */
if (r->method_number == M_GET) {
if (r->args)
else
}
else {
}
/* Check for looping, which can happen if the CGI script isn't */
return DECLINED;
/* Second, check for actions (which override the method scripts) */
"File does not exist: %s", r->filename);
return HTTP_NOT_FOUND;
}
script = t;
/* propagate the handler name to the script
* (will be REDIRECT_HANDLER there)
*/
}
return DECLINED;
return OK;
}
static void register_hooks(apr_pool_t *p)
{
}
{
create_action_dir_config, /* dir config creater */
merge_action_dir_configs, /* dir merger --- default is to override */
NULL, /* server config */
NULL, /* merge server config */
action_cmds, /* command apr_table_t */
register_hooks /* register hooks */
};