You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Taisuke Yamada <ta...@iij.ad.jp> on 2002/08/22 10:10:40 UTC
[PATCH] OPTIONS for CGI (mod_cgi)
Hi.
I wrote a small CGI script to make any CGI-enabled server into WebDAV
resource, but I noticed mod_cgi is blocking certain HTTP/WebDAV request
to make it run properly. I had to patch mod_cgi.c.
Is there any reason to prohibit CGI script from handling methods
other than GET and HEAD? In mod_cgi.c (both 1.3 and 2.0), it says:
if (r->method_number == M_OPTIONS) {
/* 99 out of 100 CGI scripts, this is all they support */
r->allowed |= (AP_METHOD_BIT << M_GET);
r->allowed |= (AP_METHOD_BIT << M_POST);
return DECLINED;
}
but I can't think of any reason to prohibit it just because 99
out of 100 CGI scripts don't support it.
My patch (this is for 1.3) adds new directive "PassThruRequest (on|off)"
to allow CGI script handle any HTTP request method.
--
Taisuke Yamada <ta...@iij.ad.jp>
Internet Initiative Japan Inc., Technical Planning Division
--- cut here --- cut here --- cut here --- cut here --- cut here ---
--- mod_cgi.c.orig Mon Mar 4 13:35:06 2002
+++ mod_cgi.c Mon Mar 4 13:33:16 2002
@@ -102,6 +102,7 @@
char *logname;
long logbytes;
int bufbytes;
+ int passthru;
} cgi_server_conf;
static void *create_cgi_config(pool *p, server_rec *s)
@@ -112,6 +113,7 @@
c->logname = NULL;
c->logbytes = DEFAULT_LOGBYTES;
c->bufbytes = DEFAULT_BUFBYTES;
+ c->passthru = 1;
return c;
}
@@ -153,6 +155,16 @@
return NULL;
}
+static const char *set_passthru(cmd_parms *cmd, void *dummy, int flag)
+{
+ server_rec *s = cmd->server;
+ cgi_server_conf *conf =
+ (cgi_server_conf *) ap_get_module_config(s->module_config, &cgi_module);
+
+ conf->passthru = flag;
+ return NULL;
+}
+
static const command_rec cgi_cmds[] =
{
{"ScriptLog", set_scriptlog, NULL, RSRC_CONF, TAKE1,
@@ -161,6 +173,8 @@
"the maximum length (in bytes) of the script debug log"},
{"ScriptLogBuffer", set_scriptlog_buffer, NULL, RSRC_CONF, TAKE1,
"the maximum size (in bytes) to record of a POST request"},
+ {"PassThruRequest", set_passthru, NULL, OR_ALL, FLAG,
+ "whether or not to let CGI handle all requests, including OPTIONS"},
{NULL}
};
@@ -380,7 +394,7 @@
struct cgi_child_stuff cld;
- if (r->method_number == M_OPTIONS) {
+ if (! conf->passthru && r->method_number == M_OPTIONS) {
/* 99 out of 100 CGI scripts, this is all they support */
r->allowed |= (1 << M_GET);
r->allowed |= (1 << M_POST);
Re: [PATCH] OPTIONS for CGI (mod_cgi)
Posted by Taisuke Yamada <ta...@iij.ad.jp>.
> ... I noticed mod_cgi is blocking certain HTTP/WebDAV request to
> make it run properly. I had to patch mod_cgi.c.
>
> My patch (this is for 1.3) adds new directive "PassThruRequest
> (on|off)" to allow CGI script handle any HTTP request method.
I should have noticed, but my report is exactly same as 3-year old
PR#4490 for mod_cgi:
http://www.geocrawler.com/archives/3/192/1999/5/0/2165608/
Apparently, it is not closed (still couldn't find it in Apache bug
database...) and this past thread ends with the following reply:
I suggest a directive name involving the words "OPTIONS," "CGI,"
and "Pass." There is no guarantee when/if it will be accepted
or make it into the source, but it`s more likely if there`s a
patch for it than otherwise.
I also found a patch made for Zope WebDAV support, and this too,
seems to be available since late 1999:
http://www.zope.org/Members/Brian/Misc/mod_cgi_webdav_patch.html
Was this PR simply forgotten, or is there any reason for not
getting it in?
--
Taisuke Yamada <ta...@iij.ad.jp>
Internet Initiative Japan Inc., Technical Planning Division