mod_headers.c revision b4c8a80f7dbfc9b56dbe03bdc28f0b5eb5f23697
/* ====================================================================
* Copyright (c) 1996-1999 The Apache Group. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the Apache Group
* for use in the Apache HTTP server project (http://www.apache.org/)."
*
* 4. The names "Apache Server" and "Apache Group" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the Apache Group
* for use in the Apache HTTP server project (http://www.apache.org/)."
*
* THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Group and was originally based
* on public domain software written at the National Center for
* Supercomputing Applications, University of Illinois, Urbana-Champaign.
* For more information on the Apache Group and the Apache HTTP server
* project, please see <http://www.apache.org/>.
*
*/
/*
* mod_headers.c: Add/append/remove HTTP response headers
* Written by Paul Sutton, paul@ukweb.com, 1 Oct 1996
*
* Valid in both per-server and per-dir configurations.
*
* Syntax is:
*
* Header action header value
*
* Where action is one of:
* set - set this header, replacing any old value
* add - add this header, possible resulting in two or more
* headers with the same name
* append - append this text onto any existing header of this same
* unset - remove this header
*
* Where action is unset, the third argument (value) should not be given.
* The header name can include the colon, or not.
*
* The Header directive can only be used where allowed by the FileInfo
* override.
*
* When the request is processed, the header directives are processed in
* this order: firstly, the main server, then the virtual server handling
* this request (if any), then any <Directory> sections (working downwards
* from the root dir), then an <Location> sections (working down from
* shortest URL component), the any <File> sections. This order is
* important if any 'set' or 'unset' actions are used. For example,
* the following two directives have different effect if applied in
* the reverse order:
*
* Header append Author "John P. Doe"
* Header unset Author
*
* Examples:
*
* To set the "Author" header, use
* Header add Author "John P. Doe"
*
* To remove a header:
* Header unset Author
*
*/
#include "httpd.h"
#include "http_config.h"
typedef enum {
} hdr_actions;
typedef struct {
char *header;
char *value;
} header_entry;
/*
* headers_conf is our per-module configuration. This is used as both
* a per-dir and per-server config
*/
typedef struct {
} headers_conf;
{
headers_conf *a =
return a;
}
static void *create_headers_dir_config(ap_context_t *p, char *d)
{
}
{
headers_conf *a =
return a;
}
static const char *header_cmd(cmd_parms *cmd, headers_conf * dirconf, char *action, char *hdr, char *value)
{
char *colon;
}
else {
}
else
return "first argument must be add, set, append or unset.";
if (value)
return "Header unset takes two arguments";
}
else if (!value)
return "Header requires three arguments";
*colon = '\0';
return NULL;
}
static const command_rec headers_cmds[] =
{
"an action, header and value"},
{NULL}
};
{
int i;
case hdr_add:
break;
case hdr_append:
break;
case hdr_set:
break;
case hdr_unset:
break;
}
}
}
static int fixup_headers(request_rec *r)
{
void *dconf = r->per_dir_config;
return DECLINED;
}
static void register_hooks(void)
{
}
{
create_headers_dir_config, /* dir config creater */
merge_headers_config, /* dir merger --- default is to override */
create_headers_config, /* server config */
merge_headers_config, /* merge server configs */
headers_cmds, /* command ap_table_t */
NULL, /* handlers */
register_hooks /* register hooks */
};