/* Licensed to the Apache Software Foundation (ASF) under one or more *contributorlicenseagreements.SeetheNOTICEfiledistributedwith *thisworkforadditionalinformationregardingcopyrightownership. *TheASFlicensesthisfiletoYouundertheApacheLicense,Version2.0 *(the"License");youmaynotusethisfileexceptincompliancewith *theLicense.YoumayobtainacopyoftheLicenseat * *http://www.apache.org/licenses/LICENSE-2.0 * *Unlessrequiredbyapplicablelaworagreedtoinwriting,software *distributedundertheLicenseisdistributedonan"ASIS"BASIS, *WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied. *SeetheLicenseforthespecificlanguagegoverningpermissionsand *limitationsundertheLicense.
*/
typedefstruct {
apr_hash_t *extension_mappings; /* Map from extension name to
* extension_info structure */
apr_array_header_t *remove_mappings; /* A simple list, walked once */
char *default_language; /* Language if no AddLanguage ext found */
int multimatch; /* Extensions to include in multiview matching *forfilenames,e.g.FiltersandHandlers
*/ int use_path_info; /* If set to 0, only use filename. *Ifsetto1,appendPATH_INFOtofilenamefor *lookups. *Ifsetto2,thisvalueisunsetandis *effectively0.
*/
} mime_dir_config;
if (base->extension_mappings && add->extension_mappings) { new->extension_mappings = apr_hash_merge(p, add->extension_mappings,
base->extension_mappings,
overlay_extension_mappings,
NULL);
} else { if (base->extension_mappings == NULL) { new->extension_mappings = add->extension_mappings;
} else { new->extension_mappings = base->extension_mappings;
} /* We may not be merging the tables, but if we potentially will change *anexinfomember,thenweareabouttotrounceitanyways. *Wemusthaveacopyforsafety.
*/ if (new->extension_mappings && add->remove_mappings) { new->extension_mappings =
apr_hash_copy(p, new->extension_mappings);
}
}
if (new->extension_mappings) { if (add->remove_mappings)
remove_items(p, add->remove_mappings, new->extension_mappings);
} new->remove_mappings = NULL;
if (strcasecmp(include, "Any") == 0) { if (m->multimatch && (m->multimatch & ~MULTIMATCH_ANY)) { return"Any is incompatible with NegotiatedOnly, " "Filters and Handlers";
}
m->multimatch |= MULTIMATCH_ANY;
} elseif (strcasecmp(include, "NegotiatedOnly") == 0) { if (m->multimatch && (m->multimatch & ~MULTIMATCH_NEGOTIATED)) { return"NegotiatedOnly is incompatible with Any, " "Filters and Handlers";
}
m->multimatch |= MULTIMATCH_NEGOTIATED;
} elseif (strcasecmp(include, "Filters") == 0) { if (m->multimatch && (m->multimatch & (MULTIMATCH_NEGOTIATED
| MULTIMATCH_ANY))) { return"Filters is incompatible with Any and NegotiatedOnly";
}
m->multimatch |= MULTIMATCH_FILTERS;
} elseif (strcasecmp(include, "Handlers") == 0) { if (m->multimatch && (m->multimatch & (MULTIMATCH_NEGOTIATED
| MULTIMATCH_ANY))) { return"Handlers is incompatible with Any and NegotiatedOnly";
}
m->multimatch |= MULTIMATCH_HANDLERS;
} else { return apr_psprintf(cmd->pool, "Unrecognized option '%s'", include);
}
return NULL;
}
staticconst command_rec mime_cmds[] =
{
AP_INIT_ITERATE2("AddCharset", add_extension_info,
(void *)APR_OFFSETOF(extension_info, charset_type), OR_FILEINFO, "a charset (e.g., iso-2022-jp), followed by one or more " "file extensions"),
AP_INIT_ITERATE2("AddEncoding", add_extension_info,
(void *)APR_OFFSETOF(extension_info, encoding_type), OR_FILEINFO, "an encoding (e.g., gzip), followed by one or more file extensions"),
AP_INIT_ITERATE2("AddHandler", add_extension_info,
(void *)APR_OFFSETOF(extension_info, handler), OR_FILEINFO, "a handler name followed by one or more file extensions"),
AP_INIT_ITERATE2("AddInputFilter", add_extension_info,
(void *)APR_OFFSETOF(extension_info, input_filters), OR_FILEINFO, "input filter name (or ; delimited names) followed by one or " "more file extensions"),
AP_INIT_ITERATE2("AddLanguage", add_extension_info,
(void *)APR_OFFSETOF(extension_info, language_type), OR_FILEINFO, "a language (e.g., fr), followed by one or more file extensions"),
AP_INIT_ITERATE2("AddOutputFilter", add_extension_info,
(void *)APR_OFFSETOF(extension_info, output_filters), OR_FILEINFO, "output filter name (or ; delimited names) followed by one or " "more file extensions"),
AP_INIT_ITERATE2("AddType", add_extension_info,
(void *)APR_OFFSETOF(extension_info, forced_type), OR_FILEINFO, "a mime type followed by one or more file extensions"),
AP_INIT_TAKE1("DefaultLanguage", ap_set_string_slot,
(void*)APR_OFFSETOF(mime_dir_config, default_language), OR_FILEINFO, "language to use for documents with no other language file extension"),
AP_INIT_ITERATE("MultiviewsMatch", multiviews_match, NULL, OR_FILEINFO, "NegotiatedOnly (default), Handlers and/or Filters, or Any"),
AP_INIT_ITERATE("RemoveCharset", remove_extension_info,
(void *)APR_OFFSETOF(extension_info, charset_type), OR_FILEINFO, "one or more file extensions"),
AP_INIT_ITERATE("RemoveEncoding", remove_extension_info,
(void *)APR_OFFSETOF(extension_info, encoding_type), OR_FILEINFO, "one or more file extensions"),
AP_INIT_ITERATE("RemoveHandler", remove_extension_info,
(void *)APR_OFFSETOF(extension_info, handler), OR_FILEINFO, "one or more file extensions"),
AP_INIT_ITERATE("RemoveInputFilter", remove_extension_info,
(void *)APR_OFFSETOF(extension_info, input_filters), OR_FILEINFO, "one or more file extensions"),
AP_INIT_ITERATE("RemoveLanguage", remove_extension_info,
(void *)APR_OFFSETOF(extension_info, language_type), OR_FILEINFO, "one or more file extensions"),
AP_INIT_ITERATE("RemoveOutputFilter", remove_extension_info,
(void *)APR_OFFSETOF(extension_info, output_filters), OR_FILEINFO, "one or more file extensions"),
AP_INIT_ITERATE("RemoveType", remove_extension_type,
(void *)APR_OFFSETOF(extension_info, forced_type), OR_FILEINFO, "one or more file extensions"),
AP_INIT_TAKE1("TypesConfig", set_types_config, NULL, RSRC_CONF, "the MIME types config file"),
AP_INIT_FLAG("ModMimeUsePathInfo", ap_set_flag_slot,
(void *)APR_OFFSETOF(mime_dir_config, use_path_info), ACCESS_CONF, "Set to 'yes' to allow mod_mime to use path info for type checking"),
{NULL}
};
/* Parse filename extensions which can be in any order
*/ while (*fn && (ext = ap_getword(r->pool, &fn, '.'))) { const extension_info *exinfo = NULL; int found; char *extcase;
if (exinfo == NULL || !exinfo->forced_type) { if ((type = apr_hash_get(mime_type_extensions, ext,
APR_HASH_KEY_STRING)) != NULL) {
ap_set_content_type_ex(r, (char*) type, 1);
found = 1;
}
}
if (exinfo != NULL) {
/* empty string is treated as special case for RemoveType */ if (exinfo->forced_type && *exinfo->forced_type) {
ap_set_content_type_ex(r, exinfo->forced_type, 1);
found = 1;
}
if (exinfo->charset_type) {
charset = exinfo->charset_type;
found = 1;
} if (exinfo->language_type) { if (!r->content_languages) {
r->content_languages = apr_array_make(r->pool, 2, sizeof(char *));
}
*((constchar **)apr_array_push(r->content_languages))
= exinfo->language_type;
found = 1;
} if (exinfo->encoding_type) { if (!r->content_encoding) {
r->content_encoding = exinfo->encoding_type;
} else { /* XXX should eliminate duplicate entities * *ahno.Orderisimportantanddoubleencodingisneither *forbiddennorimpossible.--nd
*/
r->content_encoding = apr_pstrcat(r->pool,
r->content_encoding, ", ",
exinfo->encoding_type,
NULL);
}
found = 1;
} /* The following extensions are not 'Found'. That is, they don't *makeanycontributiontometadatanegotiation,sotheymusthave *beenexplicitlyrequestedbyname.
*/ if (exinfo->handler && r->proxyreq == PROXYREQ_NONE) {
r->handler = exinfo->handler; if (conf->multimatch & MULTIMATCH_HANDLERS) {
found = 1;
}
} /* XXX Two significant problems; 1, we don't check to see if we are *settingredundantfilters.2,weinserttheseinthetypes *confighook,whichmaybetooearly(dunno.)
*/ if (exinfo->input_filters) { constchar *filter, *filters = exinfo->input_filters; while (*filters
&& (filter = ap_getword(r->pool, &filters, ';'))) {
ap_add_input_filter(filter, NULL, r, r->connection);
} if (conf->multimatch & MULTIMATCH_FILTERS) {
found = 1;
}
} if (exinfo->output_filters) { constchar *filter, *filters = exinfo->output_filters; while (*filters
&& (filter = ap_getword(r->pool, &filters, ';'))) {
ap_add_output_filter(filter, NULL, r, r->connection);
} if (conf->multimatch & MULTIMATCH_FILTERS) {
found = 1;
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.