Mailing List Archive

mod_mime modification.
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;
}
Re: mod_mime modification. [ In reply to ]
On Wed, 9 Aug 1995, Florent Guillaume wrote:
> 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.

Can we have this as a MultiViewsFull option or something? It's just that
we got burned last night when we turned on multiviews on our site finally
and all the "index.*.html" files had weird stuff happen. We're enforcing
discipline here on that issue now, but others might not be so disciplined
and consider it a bug/drawback.

Brian

--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
brian@organic.com brian@hyperreal.com http://www.[hyperreal,organic].com/
Re: mod_mime modification. [ In reply to ]
Date: Wed, 9 Aug 1995 12:27:43 -0700 (PDT)
From: Brian Behlendorf <brian@organic.com>
Precedence: bulk
Reply-To: new-httpd@hyperreal.com

On Wed, 9 Aug 1995, Florent Guillaume wrote:
> 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.

Can we have this as a MultiViewsFull option or something? It's just that
we got burned last night when we turned on multiviews on our site finally
and all the "index.*.html" files had weird stuff happen. We're enforcing
discipline here on that issue now, but others might not be so disciplined
and consider it a bug/drawback.

I have to agree --- this may be a good idea for the long term, but I
think it may be best to hold off on it for the next beta...

rst
Re: mod_mime modification. [ In reply to ]
> On Wed, 9 Aug 1995, Florent Guillaume wrote:
> > 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.
>
> Can we have this as a MultiViewsFull option or something? It's just that
> we got burned last night when we turned on multiviews on our site finally
> and all the "index.*.html" files had weird stuff happen. We're enforcing
> discipline here on that issue now, but others might not be so disciplined
> and consider it a bug/drawback.

The problem you're describing (things like: "index.old.html" is returned
if you ask for "index") has nothing to do with the MIME module. It's a
"misfeature" in the negotiation module that causes it. I'm planning to
fix this, by the way.

Please consider this MIME patch, as it's a behaviour that all CERN users
are expecting, and it is really harmless, as all it allows is a
permutation in the _recognized_ suffixes at the end of the filename.

It doesn't matter if it isn't in the very next release, but please
test it.


Florent