Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fcgi_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ const char *fcgi_util_socket_make_addr(apr_pool_t *p, fcgi_request_t *fr)
&fr->socket_addr_len, host, port);
}

int fcgi_request_create(request_rec *r, fcgi_request_t **frP)
int fcgi_request_create(request_rec *r, char *action, fcgi_request_t **frP)
{
apr_pool_t *p = r->pool;
fcgi_request_t *fr = apr_pcalloc(p, sizeof(fcgi_request_t));

/* setup server socket struct */
fr->server = apr_pstrdup(p, r->handler + 5);
fr->server = apr_pstrdup(p, action);

const char *err = fcgi_util_socket_make_addr(p, fr);

Expand Down
2 changes: 1 addition & 1 deletion fcgi_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ typedef struct {
int socket_fd; /* socket descriptor to FastCGI server */
} fcgi_request_t;

int fcgi_request_create(request_rec *r, fcgi_request_t **frP);
int fcgi_request_create(request_rec *r, char *action, fcgi_request_t **frP);

int fcgi_request_process(fcgi_request_t *fr);

Expand Down
36 changes: 32 additions & 4 deletions mod_fastcgi_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,25 @@
static
int fastcgi_handler(request_rec *r)
{
if (strncmp(r->handler, "fcgi:", 5))
return DECLINED;
fastcgi_handler_cfg *conf = (fastcgi_handler_cfg *)
ap_get_module_config(r->per_dir_config, &fastcgi_handler_module);
const char *action;

action = r->handler;
if (!action || strncmp(action, "fcgi:", 5)) {
const char *type;
type = ap_field_noparam(r->pool, r->content_type);
if (type)
action = apr_table_get(conf->action_types, type);
if (!action || strncmp(action, "fcgi:", 5))
return DECLINED;
}

fcgi_request_t *fr = NULL;
int ret;

/* Step 1: create a new FastCGI request object */
if ((ret = fcgi_request_create(r, &fr)) != OK) {
if ((ret = fcgi_request_create(r, action+5, &fr)) != OK) {
return ret;
}

Expand All @@ -32,6 +43,7 @@ void *fastcgi_handler_create_dir_config(apr_pool_t *p, char *dir)
fastcgi_handler_cfg *cfg = apr_pcalloc(p, sizeof(fastcgi_handler_cfg));

cfg->idle_timeout = -1;
cfg->action_types = apr_table_make(p, 4);

return cfg;
}
Expand All @@ -46,12 +58,28 @@ void *fastcgi_handler_merge_dir_config(apr_pool_t *p, void *parent, void *curren
cfg->idle_timeout = current_cfg->idle_timeout == -1 ?
parent_cfg->idle_timeout : current_cfg->idle_timeout;

cfg->action_types = apr_table_overlay(p, current_cfg->action_types,
parent_cfg->action_types);

return cfg;
}

static
const char *add_action(cmd_parms *cmd, void *m_v,
const char *type, const char *script)
{
fastcgi_handler_cfg *cfg = (fastcgi_handler_cfg *)m_v;

apr_table_setn(cfg->action_types, type, script);

return NULL;
}

static
const command_rec fastcgi_handler_cmds[] =
{
AP_INIT_TAKE2("FcgiAction", add_action, NULL, RSRC_CONF,
"a media type followed by a fcgi:socket"),
{ NULL }
};

Expand All @@ -61,7 +89,7 @@ void fastcgi_handler_register_hooks(apr_pool_t * p)
ap_hook_handler(fastcgi_handler, NULL, NULL, APR_HOOK_MIDDLE);
}

module AP_MODULE_DECLARE_DATA fastcgi_handler_module =
AP_DECLARE_MODULE(fastcgi_handler_module) =
{
STANDARD20_MODULE_STUFF,
fastcgi_handler_create_dir_config,
Expand Down
1 change: 1 addition & 0 deletions mod_fastcgi_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define FCGI_DEFAULT_IDLE_TIMEOUT 30

typedef struct {
apr_table_t *action_types;
int idle_timeout;
} fastcgi_handler_cfg;

Expand Down