You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Paul J. Reder" <re...@raleigh.ibm.com> on 2000/01/20 17:25:40 UTC

Re: [Patch]: Fix mod_mime to hook in the right order. Second attempt.

OK, I hope that I did this right this time. This should force mod_mime
to be run before mod_mime_magic. This will enable server side includes
to work again since the AddHandler code will get called for .shtml files.

This works in my testing, and doesn't seem to break anything else. YMMV.

-- 
Paul J. Reder
------------------------------------------------------------
"Remember, Information is not knowledge; Knowledge is not Wisdom;
Wisdom is not truth; Truth is not beauty; Beauty is not love;
Love is not music; Music is the best." -- Frank Zappa

Index: mod_mime.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_mime.c,v
retrieving revision 1.9
diff -u -r1.9 mod_mime.c
--- mod_mime.c  2000/01/19 02:42:09     1.9
+++ mod_mime.c  2000/01/20 15:54:39
@@ -386,7 +386,10 @@
 
 static void register_hooks(void)
 {
-    ap_hook_type_checker(find_ct,NULL,NULL,HOOK_MIDDLE);
+    static const char * const aszPost[]={ "mod_mime_magic.c", NULL };
+
+    /* mod_mime_magic should be run after mod_mime, if at all. */
+    ap_hook_type_checker(find_ct,NULL,aszPost,HOOK_MIDDLE);
     ap_hook_post_config(mime_post_config,NULL,NULL,HOOK_MIDDLE);
 }

Re: [Patch]: Fix mod_mime to hook in the right order. Second attempt.

Posted by Ben Laurie <be...@algroup.co.uk>.
Rodent of Unusual Size wrote:
> 
> Ben Laurie wrote:
> >
> > For no fantastically good reason, I feel that mod_mime_magic
> > should ask to run before mod_mime, rather than the other way
> > around, as you have it here.
> 
> Oh please no. mmm is incredibly resource-consumptive, and
> IMHO should be called as a last resort to figure something
> out that the Webmaster hasn't identified explicitly.  It
> should be called IFF there's apparently no other way to
> figure out the content-type.

I was not proposing to change the ordering, merely how it was specified.
It sounds to me, though, like we've somehow screwed up the hook, if you
are saying mmm runs after mm in the current version?

Cheers,

Ben.

--
SECURE HOSTING AT THE BUNKER! http://www.thebunker.net/hosting.htm

http://www.apache-ssl.org/ben.html

"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
     - Indira Gandhi

Re: [Patch]: Fix mod_mime to hook in the right order. Second attempt.

Posted by Rodent of Unusual Size <Ke...@Golux.Com>.
Ben Laurie wrote:
> 
> For no fantastically good reason, I feel that mod_mime_magic
> should ask to run before mod_mime, rather than the other way
> around, as you have it here.

Oh please no. mmm is incredibly resource-consumptive, and
IMHO should be called as a last resort to figure something
out that the Webmaster hasn't identified explicitly.  It
should be called IFF there's apparently no other way to
figure out the content-type.
-- 
#ken    P-)}

Ken Coar                    <http://Golux.Com/coar/>
Apache Software Foundation  <http://www.apache.org/>
"Apache Server for Dummies" <http://Apache-Server.Com/>

Come to the first official Apache Software Foundation
Conference!  <http://ApacheCon.Com/>

Re: [Patch]: Fix mod_mime to hook in the right order. Second attempt.

Posted by Ben Laurie <be...@algroup.co.uk>.
"Paul J. Reder" wrote:
> 
> Ben,
> 
> Ben Laurie wrote:
> > Umm. This is an entirely different point ... I was simply saying that I
> > felt that mod_mime_magic should ask to run before mod_mime, instead of
> > mod_mime asking to run after mod_mime_magic.
> 
> Unless I really blew something I was trying to require that mod_mime_magic
> run after mod_mime (not before). Whether that gets done by specifying that
> mod_mime_magic run after mod_mime (in mod_mime), or that mod_mime run before
> mod_mime_magic (in mod_mime_magic) I don't care.
> 
> >
> > I do get your point, but I don't understand how you propose to solve it.
> > If we run ALL, then we get mod_mime_magic's overhead in all cases.
> 
> Yes and no. If mod_mime sets a value for the content_type then
> mod_mime_magic returns right away, no wasted work. But then what is
> the value unless mod_mime_magic could override the value if it chose.
> I don't think that ALL is the answer, just a possibility.

Isn't that the behaviour you get with FIRST?

> > I suspect what we really want is for mod_mime to hook twice, once at
> > MIDDLE, once at LAST. The MIDDLE hook returns known types, or DECLINEs,
> > and the LAST hook returns default types. If mod_mime identifies it,
> > we're done. If not, we try mod_mime_magic (which wants to run _after_
> > mode_mime in this scenario), and if it identifies, we're done, if not,
> > we get the default type, from mod_mime's other hook. We still want the
> > hook to run FIRST.
> 
> This isn't the way the code is written now. If I am understanding the code
> correctly the mod_mime code either identifies a type or it doesn't. There
> is no such thing as "Identifiable" vs. "default". Right now, if mod_mime
> thinks it has the answer, mod_mime_magic never gets a shot. I believe that
> is how 1.3 works also.

Oh? I guess the default type is implemented elsewhere, then? Oh, it is
... in the core but "magically", rather than as I've suggested.

Cheers,

Ben.

--
SECURE HOSTING AT THE BUNKER! http://www.thebunker.net/hosting.htm

http://www.apache-ssl.org/ben.html

"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
     - Indira Gandhi

Re: [Patch]: Fix mod_mime to hook in the right order. Second attempt.

Posted by Ben Laurie <be...@algroup.co.uk>.
"Paul J. Reder" wrote:
> 
> Ben,
> 
> Ben Laurie wrote:
> > Umm. This is an entirely different point ... I was simply saying that I
> > felt that mod_mime_magic should ask to run before mod_mime, instead of
> > mod_mime asking to run after mod_mime_magic.
> 
> Unless I really blew something I was trying to require that mod_mime_magic
> run after mod_mime (not before). Whether that gets done by specifying that
> mod_mime_magic run after mod_mime (in mod_mime), or that mod_mime run before
> mod_mime_magic (in mod_mime_magic) I don't care.

The rest aside, what I was getting at was that mod_mime_magic (being the
more specific module) should deal with ordering, not mod_mime. Its
entirely likely that I've got the actual ordering wrong, though - that's
not important.

Cheers,

Ben.

--
SECURE HOSTING AT THE BUNKER! http://www.thebunker.net/hosting.htm

http://www.apache-ssl.org/ben.html

"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
     - Indira Gandhi

Re: [Patch]: Fix mod_mime to hook in the right order. Second attempt.

Posted by "Paul J. Reder" <re...@raleigh.ibm.com>.
Ben,

Ben Laurie wrote:
> Umm. This is an entirely different point ... I was simply saying that I
> felt that mod_mime_magic should ask to run before mod_mime, instead of
> mod_mime asking to run after mod_mime_magic.

Unless I really blew something I was trying to require that mod_mime_magic
run after mod_mime (not before). Whether that gets done by specifying that
mod_mime_magic run after mod_mime (in mod_mime), or that mod_mime run before 
mod_mime_magic (in mod_mime_magic) I don't care.

> 
> I do get your point, but I don't understand how you propose to solve it.
> If we run ALL, then we get mod_mime_magic's overhead in all cases.

Yes and no. If mod_mime sets a value for the content_type then
mod_mime_magic returns right away, no wasted work. But then what is
the value unless mod_mime_magic could override the value if it chose.
I don't think that ALL is the answer, just a possibility.

> 
> I suspect what we really want is for mod_mime to hook twice, once at
> MIDDLE, once at LAST. The MIDDLE hook returns known types, or DECLINEs,
> and the LAST hook returns default types. If mod_mime identifies it,
> we're done. If not, we try mod_mime_magic (which wants to run _after_
> mode_mime in this scenario), and if it identifies, we're done, if not,
> we get the default type, from mod_mime's other hook. We still want the
> hook to run FIRST.

This isn't the way the code is written now. If I am understanding the code 
correctly the mod_mime code either identifies a type or it doesn't. There
is no such thing as "Identifiable" vs. "default". Right now, if mod_mime
thinks it has the answer, mod_mime_magic never gets a shot. I believe that
is how 1.3 works also.

-- 
Paul J. Reder
------------------------------------------------------------
"Remember, Information is not knowledge; Knowledge is not Wisdom;
Wisdom is not truth; Truth is not beauty; Beauty is not love;
Love is not music; Music is the best." -- Frank Zappa

Re: [Patch]: Fix mod_mime to hook in the right order. Second attempt.

Posted by Ben Laurie <be...@algroup.co.uk>.
"Paul J. Reder" wrote:
> 
> Ben,
> 
> For one (possibly fantasticly) good reason. If there is a type and
> handler registered with mod_mime (say AddHandler server-parsed .shtml
> AddType text/html .shtml), but mod_mime_magic is run first then the
> shtml file will be (correctly) identified as text/html, but the
> handler will never be called. Thus server side includes are broken.
> 
> This happens partly because this hook is created to run FIRST rather
> than ALL. So when mod_mime_magic returns OK, its all over. Not to
> mention that if mod_mime can correctly identify the file, why pay the
> performance price of mod_mime_magic for every request.

Umm. This is an entirely different point ... I was simply saying that I
felt that mod_mime_magic should ask to run before mod_mime, instead of
mod_mime asking to run after mod_mime_magic.

I do get your point, but I don't understand how you propose to solve it.
If we run ALL, then we get mod_mime_magic's overhead in all cases.

I suspect what we really want is for mod_mime to hook twice, once at
MIDDLE, once at LAST. The MIDDLE hook returns known types, or DECLINEs,
and the LAST hook returns default types. If mod_mime identifies it,
we're done. If not, we try mod_mime_magic (which wants to run _after_
mode_mime in this scenario), and if it identifies, we're done, if not,
we get the default type, from mod_mime's other hook. We still want the
hook to run FIRST.

Cheers,

Ben.

--
SECURE HOSTING AT THE BUNKER! http://www.thebunker.net/hosting.htm

http://www.apache-ssl.org/ben.html

"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
     - Indira Gandhi

Re: [Patch]: Fix mod_mime to hook in the right order. Second attempt.

Posted by "Paul J. Reder" <re...@raleigh.ibm.com>.
Ben,

For one (possibly fantasticly) good reason. If there is a type and
handler registered with mod_mime (say AddHandler server-parsed .shtml
AddType text/html .shtml), but mod_mime_magic is run first then the
shtml file will be (correctly) identified as text/html, but the
handler will never be called. Thus server side includes are broken.

This happens partly because this hook is created to run FIRST rather
than ALL. So when mod_mime_magic returns OK, its all over. Not to
mention that if mod_mime can correctly identify the file, why pay the
performance price of mod_mime_magic for every request.

Ben Laurie wrote:
> 
> For no fantastically good reason, I feel that mod_mime_magic should ask
> to run before mod_mime, rather than the other way around, as you have it
> here.
> 
> Chers,
> 
> Ben.
> 
-- 
Paul J. Reder
------------------------------------------------------------
"Remember, Information is not knowledge; Knowledge is not Wisdom;
Wisdom is not truth; Truth is not beauty; Beauty is not love;
Love is not music; Music is the best." -- Frank Zappa

Re: [Patch]: Fix mod_mime to hook in the right order. Second attempt.

Posted by rb...@apache.org.
> For no fantastically good reason, I feel that mod_mime_magic should ask
> to run before mod_mime, rather than the other way around, as you have it
> here.

I really disagree.  Mod_mime_magic's docs say it should be used after
mod_mime. 

"This should be listed before mod_mime in the build Configuration file so
that it will be used after mod_mime.  mod_mime_magic is intended as a
"second line of defense" for cases mod_mime cannot resolve.

Plus, mod_mime_magic is horribly innefficient, so if we can avoid using it
because mod_mime can detect the type, then we should.

Ryan


> > Index: mod_mime.c
> > ===================================================================
> > RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_mime.c,v
> > retrieving revision 1.9
> > diff -u -r1.9 mod_mime.c
> > --- mod_mime.c  2000/01/19 02:42:09     1.9
> > +++ mod_mime.c  2000/01/20 15:54:39
> > @@ -386,7 +386,10 @@
> > 
> >  static void register_hooks(void)
> >  {
> > -    ap_hook_type_checker(find_ct,NULL,NULL,HOOK_MIDDLE);
> > +    static const char * const aszPost[]={ "mod_mime_magic.c", NULL };
> > +
> > +    /* mod_mime_magic should be run after mod_mime, if at all. */
> > +    ap_hook_type_checker(find_ct,NULL,aszPost,HOOK_MIDDLE);
> >      ap_hook_post_config(mime_post_config,NULL,NULL,HOOK_MIDDLE);
> >  }
> 
> --
> SECURE HOSTING AT THE BUNKER! http://www.thebunker.net/hosting.htm
> 
> http://www.apache-ssl.org/ben.html
> 
> "My grandfather once told me that there are two kinds of people: those
> who work and those who take the credit. He told me to try to be in the
> first group; there was less competition there."
>      - Indira Gandhi
> 


Come to the first official Apache Software Foundation
Conference!!!   <http://ApacheCon.Com/>

_______________________________________________________________________________
Ryan Bloom                        	rbb@ntrnet.net
2121 Stonehenge Dr. Apt #3
Raleigh, NC 27615		Ryan Bloom -- thinker, adventurer, artist,
				     writer, but mostly, friend.
-------------------------------------------------------------------------------


Re: [Patch]: Fix mod_mime to hook in the right order. Second attempt.

Posted by Ben Laurie <be...@algroup.co.uk>.
"Paul J. Reder" wrote:
> 
> OK, I hope that I did this right this time. This should force mod_mime
> to be run before mod_mime_magic. This will enable server side includes
> to work again since the AddHandler code will get called for .shtml files.
> 
> This works in my testing, and doesn't seem to break anything else. YMMV.

For no fantastically good reason, I feel that mod_mime_magic should ask
to run before mod_mime, rather than the other way around, as you have it
here.

Chers,

Ben.

> 
> --
> Paul J. Reder
> ------------------------------------------------------------
> "Remember, Information is not knowledge; Knowledge is not Wisdom;
> Wisdom is not truth; Truth is not beauty; Beauty is not love;
> Love is not music; Music is the best." -- Frank Zappa
> 
> Index: mod_mime.c
> ===================================================================
> RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_mime.c,v
> retrieving revision 1.9
> diff -u -r1.9 mod_mime.c
> --- mod_mime.c  2000/01/19 02:42:09     1.9
> +++ mod_mime.c  2000/01/20 15:54:39
> @@ -386,7 +386,10 @@
> 
>  static void register_hooks(void)
>  {
> -    ap_hook_type_checker(find_ct,NULL,NULL,HOOK_MIDDLE);
> +    static const char * const aszPost[]={ "mod_mime_magic.c", NULL };
> +
> +    /* mod_mime_magic should be run after mod_mime, if at all. */
> +    ap_hook_type_checker(find_ct,NULL,aszPost,HOOK_MIDDLE);
>      ap_hook_post_config(mime_post_config,NULL,NULL,HOOK_MIDDLE);
>  }

--
SECURE HOSTING AT THE BUNKER! http://www.thebunker.net/hosting.htm

http://www.apache-ssl.org/ben.html

"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
     - Indira Gandhi