httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexei Kosut <>
Subject filetype-based script execution
Date Mon, 21 Aug 1995 22:32:40 GMT

I've uploaded to /httpd/incoming on hyperreal a module I just wrote,
mod_action.c. It's a cross between mod_cgi.c, mod_mime.c and mod_include.c
that implements a command that was called "AddHandler" by rst in his
vetoed patch for 0.6.2. But I like WebSTAR's name better, so I used it. 
Anyhow, it works as follows: 

Action mime/type /cgi/script

If this entry is placed into srm.conf, and a file with a content type of
mime/type is requested, /cgi/script will be executed (assuming it's a
valid CGI script). In addition to most of the usual CGI variables (some,
notably SCRIPT_NAME, are not set, since they're not applicable, or even
possible), it sends DOCUMENT_URI, like with server-side includes, which
specifies the URI for the requested document, and DOCUMENT_TRANSLATED,
which specified the location in the filesystem where the document can be

For example, if Apache didn't have the send-as-is module, you could 
implement that feature as follows:

AddType httpd/send-as-is asis
Action httpd/send-asis /usr/local/etc/httpd/cgi-bin/send-as-is

where /usr/local/etc/httpd/cgi-bin/send-as-is is a file contaiining:

-- cut here --

-- cut here --

Assuming that /usr/local/etc/httpd/cgi-bin is either ExexCGIed or 
ScriptAliased, and send-as-is is mode +x, this should perform almost 
exactly the current as-is function. Rather simple, don't you think? Four 
lines total, vs. the 114 lines that mod_asis.c occupies.

At any rate, this module is obviously rather useful (at least, IMO), and
if people like it, I'd like to see it included in whatever next Apache
release contains new features. If not, or at least until that time, can it
be stuck in /contrib/modules?

Disclaimer: I'm not a great C programmer, and I've probably done things
with this code that would make even Microsoft employees scream and run for
the hills. There's also probably a much easier way to do this. However, it
seems to work, and on my machine (HP-UX 9.04), it has yet to do something
wrong (although I've only been testing it for an hour or so).


--/ Alexei Kosut <> /--------/ Lefler on IRC
----------------------------/ <>
The viewpoints expressed above are entirely false, and in no way
represent Alexei Kosut nor any other person or entity. /--------------

View raw message