This patch changes the MIME module, in that now the suffixes are accepted
in any order. Thus you can use
index.html.en
index.gz.html.fr
etc.
and all of them are typed correctly.
This patch is a basis for a future patch that will have extended
content-negotation possibilities (i.e. index.gz will be able to return
index.html.en.gz).
Florent
[.this is a patch over 0.8.8, I hope it works with 0.8.9]
*** mod_mime.c.orig Tue Aug 1 02:47:15 1995
--- mod_mime.c Wed Aug 9 18:56:47 1995
***************
*** 200,247 ****
int find_ct(request_rec *r)
{
int i;
! char *fn = pstrdup (r->pool, r->filename);
! mime_dir_config *conf =
! (mime_dir_config *)get_module_config(r->per_dir_config, &mime_module);
char *type;
if (S_ISDIR(r->finfo.st_mode)) {
r->content_type = DIR_MAGIC_TYPE;
return OK;
}
! if((i=rind(fn,'.')) < 0) return DECLINED;
! ++i;
!
! if ((type = table_get (conf->encoding_types, &fn[i])))
! {
! r->content_encoding = type;
!
! /* go back to previous extension to try to use it as a language */
!
! fn[i-1] = '\0';
! if((i=rind(fn,'.')) < 0) return OK;
! ++i;
}
! if ((type = table_get (conf->language_types, &fn[i])))
! {
! r->content_language = type;
!
! /* go back to previous extension to try to use it as a type */
!
! fn[i-1] = '\0';
! if((i=rind(fn,'.')) < 0) return OK;
! ++i;
! }
! if ((type = table_get (conf->forced_types, &fn[i]))
! || (type = table_get (hash_buckets[hash(fn[i])], &fn[i])))
! {
! r->content_type = type;
! }
!
! return OK;
}
--- 200,252 ----
int find_ct(request_rec *r)
{
int i;
! char *fn;
! mime_dir_config *conf;
char *type;
+ int did_type, did_lang, did_enc;
if (S_ISDIR(r->finfo.st_mode)) {
r->content_type = DIR_MAGIC_TYPE;
return OK;
}
! /*
! * Scan through suffixes, starting at the end.
! * Stop if the suffix is unknown.
! */
!
! did_type = did_lang = did_enc = 0;
! fn = pstrdup (r->pool, r->filename);
! conf =
! (mime_dir_config *) get_module_config(r->per_dir_config, &mime_module);
!
! while ((i = rind (fn, '.')) >= 0) {
! i++;
! if (!did_enc
! && (type = table_get (conf->encoding_types, &fn[i]))) {
! did_enc = 1;
! r->content_encoding = type;
! fn[i-1] = '\0';
! } else if (!did_type
! && ( (type = table_get (conf->forced_types, &fn[i]))
! || (type = table_get (hash_buckets[hash(fn[i])],
! &fn[i])))) {
! did_type = 1;
! r->content_type = type;
! fn[i-1] = '\0';
! } else if (!did_lang
! && (type = table_get (conf->language_types, &fn[i]))) {
! did_lang = 1;
! r->content_language = type;
! fn[i-1] = '\0';
! } else
! break;
}
! if (did_type || did_lang || did_enc)
! return OK;
! return DECLINED;
}
in any order. Thus you can use
index.html.en
index.gz.html.fr
etc.
and all of them are typed correctly.
This patch is a basis for a future patch that will have extended
content-negotation possibilities (i.e. index.gz will be able to return
index.html.en.gz).
Florent
[.this is a patch over 0.8.8, I hope it works with 0.8.9]
*** mod_mime.c.orig Tue Aug 1 02:47:15 1995
--- mod_mime.c Wed Aug 9 18:56:47 1995
***************
*** 200,247 ****
int find_ct(request_rec *r)
{
int i;
! char *fn = pstrdup (r->pool, r->filename);
! mime_dir_config *conf =
! (mime_dir_config *)get_module_config(r->per_dir_config, &mime_module);
char *type;
if (S_ISDIR(r->finfo.st_mode)) {
r->content_type = DIR_MAGIC_TYPE;
return OK;
}
! if((i=rind(fn,'.')) < 0) return DECLINED;
! ++i;
!
! if ((type = table_get (conf->encoding_types, &fn[i])))
! {
! r->content_encoding = type;
!
! /* go back to previous extension to try to use it as a language */
!
! fn[i-1] = '\0';
! if((i=rind(fn,'.')) < 0) return OK;
! ++i;
}
! if ((type = table_get (conf->language_types, &fn[i])))
! {
! r->content_language = type;
!
! /* go back to previous extension to try to use it as a type */
!
! fn[i-1] = '\0';
! if((i=rind(fn,'.')) < 0) return OK;
! ++i;
! }
! if ((type = table_get (conf->forced_types, &fn[i]))
! || (type = table_get (hash_buckets[hash(fn[i])], &fn[i])))
! {
! r->content_type = type;
! }
!
! return OK;
}
--- 200,252 ----
int find_ct(request_rec *r)
{
int i;
! char *fn;
! mime_dir_config *conf;
char *type;
+ int did_type, did_lang, did_enc;
if (S_ISDIR(r->finfo.st_mode)) {
r->content_type = DIR_MAGIC_TYPE;
return OK;
}
! /*
! * Scan through suffixes, starting at the end.
! * Stop if the suffix is unknown.
! */
!
! did_type = did_lang = did_enc = 0;
! fn = pstrdup (r->pool, r->filename);
! conf =
! (mime_dir_config *) get_module_config(r->per_dir_config, &mime_module);
!
! while ((i = rind (fn, '.')) >= 0) {
! i++;
! if (!did_enc
! && (type = table_get (conf->encoding_types, &fn[i]))) {
! did_enc = 1;
! r->content_encoding = type;
! fn[i-1] = '\0';
! } else if (!did_type
! && ( (type = table_get (conf->forced_types, &fn[i]))
! || (type = table_get (hash_buckets[hash(fn[i])],
! &fn[i])))) {
! did_type = 1;
! r->content_type = type;
! fn[i-1] = '\0';
! } else if (!did_lang
! && (type = table_get (conf->language_types, &fn[i]))) {
! did_lang = 1;
! r->content_language = type;
! fn[i-1] = '\0';
! } else
! break;
}
! if (did_type || did_lang || did_enc)
! return OK;
! return DECLINED;
}