Name
Type Checker
Synopsis
int module_type_checker(request_rec *pReq)
At this stage, we have almost finished
processing the request. All that is left to decide is who actually
handles it. This is done in two stages: first, by converting the URL
or filename into a MIME type or handler string, language, and
encoding; and second, by calling the appropriate function for the
type. This hook deals with the first part. If it generates a MIME
type, it should be stored in
pReq->content_type
. Alternatively, if it
generates a handler string, it should be stored in
pReq->handler
. The languages go in
pReq->content_languages
, and the encoding in
pReq->content_encoding
. Note that there is no
defined way of generating a unique handler string. Furthermore,
handler strings and MIME types are matched to the request handler
through the same table, so the handler string should probably not be
a MIME type.[7]
One obvious place that this must go on is in mod_mime.c. See Example 21-20.
Example
int find_ct(request_rec *r) { char *fn = strrchr(r->filename, '/'.; mime_dir_config *conf = (mime_dir_config *)ap_get_module_config(r->per_dir_config, &mime_module); char *ext, *type, *orighandler = r->handler; if (S_ISDIR(r->finfo.st_mode)) { r->content_type = DIR_MAGIC_TYPE; return OK; } if(fn == NULL) fn = r->filename; /* Parse filename extensions, which can be in any order */ while ((ext = getword(r->pool, &fn, '.')) && *ext) { int found = 0; /* Check for Content-Type */ if ((type ...
Get Apache: The Definitive Guide, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.