mod_cern_meta.c revision 577a76180006add04a166b12f1ad130aeedeaa5e
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco/* ====================================================================
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * Copyright (c) 1995-1999 The Apache Group. All rights reserved.
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * Redistribution and use in source and binary forms, with or without
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * modification, are permitted provided that the following conditions
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * 1. Redistributions of source code must retain the above copyright
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * notice, this list of conditions and the following disclaimer.
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * 2. Redistributions in binary form must reproduce the above copyright
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * notice, this list of conditions and the following disclaimer in
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * the documentation and/or other materials provided with the
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * distribution.
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * 3. All advertising materials mentioning features or use of this
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * software must display the following acknowledgment:
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * "This product includes software developed by the Apache Group
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * for use in the Apache HTTP server project (http://www.apache.org/)."
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * 4. The names "Apache Server" and "Apache Group" must not be used to
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * endorse or promote products derived from this software without
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * prior written permission. For written permission, please contact
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * apache@apache.org.
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * 5. Products derived from this software may not be called "Apache"
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * nor may "Apache" appear in their names without prior written
e7443960658cc31ccf48ea5b9833b13887ee14e7Lubos Kosco * permission of the Apache Group.
aa437711254f8bb8be871b7d0a4b530b718cbf4eLubos Kosco * 6. Redistributions of any form whatsoever must retain the following
aa437711254f8bb8be871b7d0a4b530b718cbf4eLubos Kosco * acknowledgment:
aa437711254f8bb8be871b7d0a4b530b718cbf4eLubos Kosco * "This product includes software developed by the Apache Group
aa437711254f8bb8be871b7d0a4b530b718cbf4eLubos Kosco * for use in the Apache HTTP server project (http://www.apache.org/)."
aa437711254f8bb8be871b7d0a4b530b718cbf4eLubos Kosco * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
aa437711254f8bb8be871b7d0a4b530b718cbf4eLubos Kosco * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
aa437711254f8bb8be871b7d0a4b530b718cbf4eLubos Kosco * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * IT'S CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * OF THE POSSIBILITY OF SUCH DAMAGE.
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * ====================================================================
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * This software consists of voluntary contributions made by many
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * individuals on behalf of the Apache Group and was originally based
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * on public domain software written at the National Center for
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * Supercomputing Applications, University of Illinois, Urbana-Champaign.
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * For more information on the Apache Group and the Apache HTTP server
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * project, please see <http://www.apache.org/>.
aa437711254f8bb8be871b7d0a4b530b718cbf4eLubos Kosco * version 0.1.0
aa437711254f8bb8be871b7d0a4b530b718cbf4eLubos Kosco * status beta
aa437711254f8bb8be871b7d0a4b530b718cbf4eLubos Kosco * Andrew Wilson <Andrew.Wilson@cm.cf.ac.uk> 25.Jan.96
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * *** IMPORTANT ***
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * This version of mod_cern_meta.c controls Meta File behaviour on a
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * per-directory basis. Previous versions of the module defined behaviour
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * on a per-server basis. The upshot is that you'll need to revisit your
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * configuration files in order to make use of the new module.
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * Emulate the CERN HTTPD Meta file semantics. Meta files are HTTP
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * headers that can be output in addition to the normal range of
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * headers for each file accessed. They appear rather like the Apache
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * .asis files, and are able to provide a crude way of influencing
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * the Expires: header, as well as providing other curiosities.
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * There are many ways to manage meta information, this one was
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * chosen because there is already a large number of CERN users
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * who can exploit this module. It should be noted that there are probably
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * more sensitive ways of managing the Expires: header specifically.
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * The module obeys the following directives, which can appear
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * in the server's .conf files and in .htaccess files.
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * MetaFiles <on|off>
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * turns on|off meta file processing for any directory.
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * Default value is off
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * # turn on MetaFiles in this directory
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * MetaFiles on
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * MetaDir <directory name>
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * specifies the name of the directory in which Apache can find
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * meta information files. The directory is usually a 'hidden'
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * subdirectory of the directory that contains the file being
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * accessed. eg:
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * # .meta files are in the *same* directory as the
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * # file being accessed
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * the default is to look in a '.web' subdirectory. This is the
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * same as for CERN 3.+ webservers and behaviour is the same as
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * for the directive:
1b28b233e40eae109c16d5b1b917dffb64e45f94Lubos Kosco * MetaDir .web
* of the index.html/index.shtml/index.htm variants and don't
#include "httpd.h"
#include "http_config.h"
#include "util_script.h"
#include "http_log.h"
#include "http_request.h"
#define DEFAULT_METAFILES 0
char *metadir;
char *metasuffix;
char *metafiles;
return new;
return new;
return NULL;
return NULL;
return NULL;
{NULL}
char w[MAX_STRING_LEN];
p = strlen(w);
return OK;
return SERVER_ERROR;
while (*l && ap_isspace(*l))
char *tmp;
return OK;
char *metafilename;
char *last_slash;
char *real_file;
char *scrap_book;
FILE *f;
int rv;
return DECLINED;
return DECLINED;
return DECLINED;
scrap_book++;
real_file++;
return DECLINED;
NULL);
return DECLINED;
if (f == NULL) {
return DECLINED;
return FORBIDDEN;
return rv;
static void register_hooks(void)