mod_mime.c revision 50e228f0b8429c27e411611f4863fafaba403b47
f743002678eb67b99bbc29fee116b65d9530fec0wrowe/* ====================================================================
80833bb9a1bf25dcf19e814438a4b311d2e1f4cffuankg * The Apache Software License, Version 1.1
249d09d51808cb7981af99762c3b3736ca126cd5jkaluza * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
249d09d51808cb7981af99762c3b3736ca126cd5jkaluza * reserved.
249d09d51808cb7981af99762c3b3736ca126cd5jkaluza * Redistribution and use in source and binary forms, with or without
56589be3d7a3e9343370df240010c6928cc78b39jkaluza * modification, are permitted provided that the following conditions
8c4967445b49a1612b3f98c1dada65e597ecfe26trawick * 1. Redistributions of source code must retain the above copyright
8c4967445b49a1612b3f98c1dada65e597ecfe26trawick * notice, this list of conditions and the following disclaimer.
61fefed8ce5211c31b44f3a38a6e76ca055e5780trawick * 2. Redistributions in binary form must reproduce the above copyright
61fefed8ce5211c31b44f3a38a6e76ca055e5780trawick * notice, this list of conditions and the following disclaimer in
61fefed8ce5211c31b44f3a38a6e76ca055e5780trawick * the documentation and/or other materials provided with the
61fefed8ce5211c31b44f3a38a6e76ca055e5780trawick * distribution.
6001d914962deabb83a46251001612e969bdf67ajim * 3. The end-user documentation included with the redistribution,
6001d914962deabb83a46251001612e969bdf67ajim * if any, must include the following acknowledgment:
c4e8006db0cf457c68876d7d4c30dcc451d8cba7jkaluza * "This product includes software developed by the
c4e8006db0cf457c68876d7d4c30dcc451d8cba7jkaluza * Apache Software Foundation (http://www.apache.org/)."
c4e8006db0cf457c68876d7d4c30dcc451d8cba7jkaluza * Alternately, this acknowledgment may appear in the software itself,
652bacc79dd7f980249784cc8c4838e8f1de7e8acovener * if and wherever such third-party acknowledgments normally appear.
652bacc79dd7f980249784cc8c4838e8f1de7e8acovener * 4. The names "Apache" and "Apache Software Foundation" must
652bacc79dd7f980249784cc8c4838e8f1de7e8acovener * not be used to endorse or promote products derived from this
f4db898517ccc6ef1a403630de56918286d3a47eminfrin * software without prior written permission. For written
f4db898517ccc6ef1a403630de56918286d3a47eminfrin * permission, please contact apache@apache.org.
28a723b775c7666281298eab813c63ac42270f95humbedooh * 5. Products derived from this software may not be called "Apache",
28a723b775c7666281298eab813c63ac42270f95humbedooh * nor may "Apache" appear in their name, without prior written
28a723b775c7666281298eab813c63ac42270f95humbedooh * permission of the Apache Software Foundation.
067698ad30941e38ef5d7f95f1c2736c2ebc5cb9humbedooh * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
067698ad30941e38ef5d7f95f1c2736c2ebc5cb9humbedooh * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
7a437ce535a5fac890296402ba483c2f41bb6500trawick * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
7a437ce535a5fac890296402ba483c2f41bb6500trawick * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
7a437ce535a5fac890296402ba483c2f41bb6500trawick * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
d8a6de5eec06d4136839c8f7a56a6ab5acd2d3behumbedooh * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
6e1e45624d6f32110383bb0bd06c254c1dba8123humbedooh * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
77ca16c5676da23155311e13cee61e7eaba9fa3ejailletc * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
77ca16c5676da23155311e13cee61e7eaba9fa3ejailletc * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
77ca16c5676da23155311e13cee61e7eaba9fa3ejailletc * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
77ca16c5676da23155311e13cee61e7eaba9fa3ejailletc * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
921d32d80d8271da08f12fc374a69cb36d1d63b3covener * SUCH DAMAGE.
921d32d80d8271da08f12fc374a69cb36d1d63b3covener * ====================================================================
3e097af23e40c45aa32602545155f0964ab5c69dcovener * This software consists of voluntary contributions made by many
3e097af23e40c45aa32602545155f0964ab5c69dcovener * individuals on behalf of the Apache Software Foundation. For more
3e097af23e40c45aa32602545155f0964ab5c69dcovener * information on the Apache Software Foundation, please see
faea99bb676ec50ece38da6b1879aa37546483a2covener * Portions of this software are based upon public domain software
86a5604df726638a2b8085e993b4b79c4b3a5262covener * originally written at the National Center for Supercomputing Applications,
faea99bb676ec50ece38da6b1879aa37546483a2covener * University of Illinois, Urbana-Champaign.
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick * http_mime.c: Sends/gets MIME headers for requests
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick * Rob McCool
4d12805e6c18253040223ea637acd6b3b3c18f60jorton/* XXXX - fix me / EBCDIC
4d12805e6c18253040223ea637acd6b3b3c18f60jorton * there was a cludge here which would use its
e5d909f2b06bd880fb3675cd49363df981caa631trawick * own version apr_isascii(). Indicating that
a4df2cd1e1391575a327c2a90ba4315f805a0a78covener * on some platforms that might be needed.
a4df2cd1e1391575a327c2a90ba4315f805a0a78covener * #define OS_ASC(c) (c) -- for mere mortals
cb666b29f81df1d11d65002250153353568021fccovener * #define OS_ASC(c) (ebcdic2ascii[c]) -- for dino's
6a80c3c6f4b8ea7ba5e89402b8b779b09ce020e0covener * #define apr_isascii(c) ((OS_ASC(c) & 0x80) == 0)
75a230a728338d84dcfe81edd375352f34de22d0covener/* XXXXX - fix me - See note with NOT_PROXY
1f50dc34ae069adeed20b2986e5ffdefa5c410e0covenertypedef struct attrib_info {
63a5ea80bddcc84a462e40f402b4f330e0e05411covener/* Information to which an extension can be mapped
63a5ea80bddcc84a462e40f402b4f330e0e05411covenertypedef struct extension_info {
986f3ea2c314d4d4b3b937149853a0f23f6119aaminfrin char *encoding_type; /* Added with AddEncoding... */
986f3ea2c314d4d4b3b937149853a0f23f6119aaminfrin char *language_type; /* Added with AddLanguage... */
c7de1955eb0eaeabf7042902476397692672d549sftypedef struct {
509622419be000045d461ef38fb97df778fdf81djailletc apr_hash_t *extension_mappings; /* Map from extension name to
509622419be000045d461ef38fb97df778fdf81djailletc * extension_info structure */
509622419be000045d461ef38fb97df778fdf81djailletc apr_array_header_t *charsets_remove; /* List of charsets to remove */
0b9de55d178312ec929dbe417dd61199b269991djailletc apr_array_header_t *encodings_remove; /* List of encodings to remove */
0b9de55d178312ec929dbe417dd61199b269991djailletc apr_array_header_t *handlers_remove; /* List of handlers to remove */
0b9de55d178312ec929dbe417dd61199b269991djailletc apr_array_header_t *languages_remove; /* List of languages to remove */
0b9de55d178312ec929dbe417dd61199b269991djailletc apr_array_header_t *types_remove; /* List of MIME types to remove */
74e7f6c55fd67b10cb400b3f6d1dc718a303d944minfrin char *default_language; /* Language if no AddLanguage ext found */
a511a29faf2ff7ead3b67680154a624effb31aafminfrin /* Due to the FUD about JS and charsets
a511a29faf2ff7ead3b67680154a624effb31aafminfrin * default_charset is actually in src/main */
a511a29faf2ff7ead3b67680154a624effb31aafminfrintypedef struct param_s {
6d601599d3d65df0410eae6e573e75b2dbfb1fb4minfrintypedef struct {
4c02bab56a528a180bbe394d8b6e6fd9c1a3ac1esfstatic char tspecial[] = {
26c5829347f6a355c00f1ba0301d575056b69536niqstatic void *create_mime_dir_config(apr_pool_t *p, char *dummy)
ef82e8fa164e0a1f8b813f7deb6b7ead96018c94niq (mime_dir_config *) apr_palloc(p, sizeof(mime_dir_config));
4576c1a9ef54cd1e5555ee07d016a7f559f80338sf * Overlay one hash table of extension_mappings onto another
bd3f5647b96d378d9c75c954e3f13582af32c643sf apr_hash_this(index, (const void**)&key, &klen, (void**)&overlay_info);
2a7beea91d46beb41f043a84eaad060047ee04aafabien base_info = (extension_info*)apr_hash_get(base, key, klen);
584a85dd4047e38d3ed3a29b6662fcc9d100ae4csf base_info = (extension_info*)apr_palloc(p, sizeof(*base_info));
85eacfc96a04547ef25aabbc06440039715084c2jorton base_info->language_type = overlay_info->language_type;
536d2e7cd1fdec1255b8c3bdf41fdc714c506a54trawick base_info->charset_type = overlay_info->charset_type;
c967bf3bc89e8aa60dbd30d9da388e448ddc1cc4trawick/* Member is the offset within an extension_info of the pointer to reset
79c5787b92ac5f0e1cc82393816c77a006399316trawickstatic void remove_items(apr_pool_t *p, apr_array_header_t *remove,
e81785da447b469da66f218b3f0244aab507958djorton if (exinfo && *((void **)((char*)&exinfo + (apr_size_t)member))) {
3e4e54d4e3fc0123c63d57aa84ac7ad7a8c73ff8jorton exinfo = (extension_info*)apr_palloc(p, sizeof(*exinfo));
53e9b27aba029b18be814df40bcf6f0428771d1efuankg *(void **)((char*)exinfo + (apr_size_t)member) = NULL;
6bb524f1895f30265a1431afc460977d391cb36bsfstatic void *merge_mime_dir_configs(apr_pool_t *p, void *basev, void *addv)
e6dd71992459d05a676b98b7963423dc5dc1e24aminfrin mime_dir_config *new = apr_palloc(p, sizeof(mime_dir_config));
e6dd71992459d05a676b98b7963423dc5dc1e24aminfrin if (base->extension_mappings && add->extension_mappings) {
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin overlay_extension_mappings(p, base->extension_mappings,
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin overlay_extension_mappings(p, add->extension_mappings,
6249dfa569d3b4f1f539665b979a80c6e335d93etrawick if (new->extension_mappings && (add->handlers_remove
cfa64348224b66dd1c9979b809406c4d15b1c137fielding overlay_extension_mappings(p, copyhash, new->extension_mappings);
cfa64348224b66dd1c9979b809406c4d15b1c137fielding remove_items(p, add->charsets_remove, new->extension_mappings,
return new;
const char* ext)
#ifdef CASE_BLIND_FILESYSTEM
++key;
if (!m->extension_mappings) {
if (!exinfo) {
return exinfo;
const char *ext)
return NULL;
const char *ext)
return NULL;
const char *ext)
return NULL;
const char *ext)
return NULL;
const char *ext)
return NULL;
const char* ext)
++ext;
#ifdef CASE_BLIND_FILESYSTEM
return NULL;
return NULL;
return NULL;
return NULL;
return NULL;
const char *arg)
(void *)arg);
return NULL;
{NULL}
ap_configfile_t *f;
char l[MAX_STRING_LEN];
if (!types_confname)
while (ll[0]) {
ap_cfg_closefile(f);
static char *zap_sp(char *s)
char *tp;
if (s == NULL) {
return (NULL);
static int is_token(char c)
int res;
return res;
static int is_qtext(char c)
int res;
return res;
static int is_quoted_pair(char *s)
if (apr_isascii(c)) {
return (res);
int quoted = 0;
(const char *) mp);
return (NULL);
return (NULL);
cp++;
return (NULL);
return (ctp);
cp++;
return (NULL);
cp++;
cp++;
return (NULL);
cp++;
return (NULL);
return (NULL);
cp++;
quoted = 0;
if (quoted > 0) {
cp++;
cp++;
cp++;
return(NULL);
quoted = 0;
return (NULL);
cp++;
return (NULL);
return (NULL);
quoted = 0;
cp++;
return (ctp);
char *ext;
int found_metadata = 0;
return OK;
&mime_module);
++fn;
* The base name is always the first exception (i.e., "txt.html" has
int found;
found = 0;
#ifdef CASE_BLIND_FILESYSTEM
if (!r->content_languages)
if (!r->content_encoding)
r->content_encoding,
NULL);
if (found)
if (found_metadata) {
(void *)exception_list);
if (r->content_type) {
char *ct;
int override = 0;
if (!override) {
NULL);
NULL);
NULL);
const char **new;
if (!r->content_languages)
/* Check for overrides with ForceType/SetHandler */
if (!r->content_type)
return DECLINED;
return OK;