httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexei Kosut <ako...@nueva.pvt.k12.ca.us>
Subject Patch for SetType/SetHandler directives
Date Tue, 09 Apr 1996 23:15:49 GMT
Hi.

Enclosed is a (yet another) patch I'd like to see included in Apache
1.1. It's a functionality that's been discussed before, and is
generally useful, but I'd just like to run the patch by y'all
first. It's really very simple. It's based on a patch that Aram
Mirzadeh forwarded from Russell McOrmond, and adds two new directives,
SetType and SetHandler. These each go into a <Directory> section, a
<Location> section or an .htaccess file, and force the type or handler
to what their argument is.

This is useful for many things. For example, Mr. McOrmond's example
was to put "SetType applicaton/octet-stream" into a .htaccess file of
files for download. Another might be, instead of the ScriptAlias
command, you might use:

<Directory /usr/local/etc/httpd/cgi-bin>
SetHandler cgi-script
</Directory>

or, instead of the .status status module hack,

<Location /status>
SetHandler server-status
</Location>

Then simply http://servername/status will give you the status
report. Much cleaner than /status/.status, or whatnot, which is
neccessary if you want to protect the status module with access
control directives. (just stick them into the <Location> section, in
this example).

Unless someone complains, I'll commit this tomorrow (April 10) evening
(PDT). The patch follows:

Index: mod_mime.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_mime.c,v
retrieving revision 1.6
diff -c -r1.6 mod_mime.c
*** mod_mime.c	1996/04/08 13:04:59	1.6
--- mod_mime.c	1996/04/09 23:06:25
***************
*** 69,74 ****
--- 69,77 ----
      table *encoding_types;	/* Added with AddEncoding... */
      table *language_types;	/* Added with AddLanguage... */
      table *handlers;		/* Added with AddHandler...  */
+
+     char *type;			/* Type forced with SetType  */
+     char *handler;		/* Handler forced with SetHandler */
  } mime_dir_config;

  module mime_module;
***************
*** 82,87 ****
--- 85,93 ----
      new->encoding_types = make_table (p, 4);
      new->language_types = make_table (p, 4);
      new->handlers = make_table (p, 4);
+
+     new->type = NULL;
+     new->handler = NULL;

      return new;
  }
***************
*** 102,107 ****
--- 108,116 ----
      new->handlers = overlay_tables (p, add->handlers,
  					  base->handlers);

+     new->type = add->type ? add->type : base->type;
+     new->handler = add->handler ? add->handler : base->handler;
+
      return new;
  }

***************
*** 153,158 ****
--- 162,171 ----
      "a language (e.g., fr), followed by one or more file extensions" },
  { "AddHandler", add_handler, NULL, OR_FILEINFO, ITERATE2,
      "a handler name followed by one or more file extensions" },
+ { "SetType", set_string_slot, (void*)XtOffsetOf(mime_dir_config, type),
+     OR_FILEINFO, TAKE1, "a media type" },
+ { "SetHandler", set_string_slot, (void*)XtOffsetOf(mime_dir_config, handler),
+     OR_FILEINFO, TAKE1, "a handler name" },
  { "TypesConfig", set_types_config, NULL, RSRC_CONF, TAKE1,
      "the MIME types config file" },
  { NULL }
***************
*** 240,245 ****
--- 253,265 ----
  	  r->handler = type;

      }
+
+     /* Check for overrides with SetType/SetHandler */
+
+     if (conf->type && strcmp(conf->type, "none"))
+         r->content_type = pstrdup(r->pool, conf->type);
+     if (conf->handler && strcmp(conf->handler, "none"))
+         r->handler = pstrdup(r->pool, conf->handler);

      return OK;
  }


--
________________________________________________________________________
Alexei Kosut <akosut@nueva.pvt.k12.ca.us>
URL: http://www.nueva.pvt.k12.ca.us/~akosut/
Lefler on IRC, DALnet <http://www.dal.net/>




Mime
View raw message