Apache module phase termination - built in or patch?

Apache module phase termination - built in or patch?

Post by Jonathan Yard » Sat, 30 Nov 1996 04:00:00



I was charged with developing a few Apache modules for various tasks
(timed access, pay-as-you-go access and URI-based authentication for now)
and I kept running into the same problem.  Stock Apache 1.1.1 does not
appear to let an arbitrary phase (let's assume one of the authentication
phases) send response data back to the client and terminate the HTTP
transfer without error.  As far as I was able to determine, I could return
OK, REDIRECT, DECLINED or an HTTP error code in a phase, but could not
"short-ciruit" at a particular phase or module.

I needed to be able to return content in an arbitrary phase after
determining that a particular module (or phase) should have processed the
request but could not for whatever reason.  So I came up with an "escape"
patch to let me do just that.

Basically, the patch lets a module phase return a code (ESCAPE) that says
the request has been handled and that no other phases (or modules) need to
be run.  In my case, if my custom authentication handler failed, I would
dynamically mark up an HTML template, return the content to the browser
and terminate the child Apache process by returning ESCAPE.

If Apache modules can already do this, then I would prefer to use the
existing method.  If not, I will make the patch available, since I cannot
belive that I'm the only one on the planet who could benefit from this.

Jon Yarden, SysAdmin, Internet Tool & Die
--
The more laws and order are made prominent, the more thieves and
robbers there will be.
                -- Lao Tsu

 
 
 

Apache module phase termination - built in or patch?

Post by Kevin P. Ne » Mon, 02 Dec 1996 04:00:00



>I was charged with developing a few Apache modules for various tasks
>(timed access, pay-as-you-go access and URI-based authentication for now)
>and I kept running into the same problem.  Stock Apache 1.1.1 does not
>appear to let an arbitrary phase (let's assume one of the authentication
>phases) send response data back to the client and terminate the HTTP
>transfer without error.  As far as I was able to determine, I could return
>OK, REDIRECT, DECLINED or an HTTP error code in a phase, but could not
>"short-ciruit" at a particular phase or module.

Here's an idea I've been kicking around (I need to do the same thing):

Can you change the mime type for the request to a type that get's
handled by a handler that you provide?

This way you can send back whatever, and end it cleanly.
--


XCOMM "Comments in code are kinda useless, anyway."
XCOMM   -- Brian Rumple, TA for my OS class, NCSU. November 6,1996

 
 
 

Apache module phase termination - built in or patch?

Post by Jonathan Yard » Mon, 02 Dec 1996 04:00:00




: >I was charged with developing a few Apache modules for various tasks
: >(timed access, pay-as-you-go access and URI-based authentication for now)
: >and I kept running into the same problem.  Stock Apache 1.1.1 does not
: >appear to let an arbitrary phase (let's assume one of the authentication
: >phases) send response data back to the client and terminate the HTTP
: >transfer without error.  As far as I was able to determine, I could return
: >OK, REDIRECT, DECLINED or an HTTP error code in a phase, but could not
: >"short-ciruit" at a particular phase or module.

: Here's an idea I've been kicking around (I need to do the same thing):

: Can you change the mime type for the request to a type that get's
: handled by a handler that you provide?

This was about the third or fourth thing that I tried.  It worked, but I
was still not able to return a response anywhere I needed to.  I had to
wait for the handler to kick in, which required that I pre-fill a
structure with the data I wanted to return and come up with my own set of
codes indicating what happened.  It did work, but was not as clean as
simply terminating the module at the phase that failed.

I've gotten several responses regarding the code, so I will probably put
it in an FTP site and send it to the Apache team.  It makes writing Apache
modules much more straightforward, although it's certainly not the best
way to do this.

Jon
--
The more laws and order are made prominent, the more thieves and
robbers there will be.
                -- Lao Tsu

 
 
 

1. Patch: linux-2.5.41/drivers/ide - build IDE as a module

        The following patch seems to fix building IDE as a module
in 2.5.41.  I am running this code on the machine that I'm using to
compose this email.

        A couple of notes:

        1. For the time being, I have reassembled some of the
drivers/ide object files into ide-mod.o again, because there are some
circular references (not necessarily a bad thing) that modprobe cannot
otherwise handle.  For now, this includes putting ide-probe in
ide-mod.

        2. I have changed cmd640.o and legacy.o from dep_bool to
dep_tristate and made them also depend on $CONFIG_BLK_DEV_IDE, so
that they will only be offered as modules if ide-mod.o is a
module (since, like any IDE driver, they require some symbols in
ide-mod.o).

        These changes are probably not perfect, but I think they
should be an improvement with no real disadvantages in comparison to
what they replace, so I would encourage you to integrate the changes
if you see no problem.  Please let me know what you want to do, or if
there is something more you'd like me to do regarding this patch.

--
Adam J. Richter     __     ______________   575 Oroville Road

+1 408 309-6081         | g g d r a s i l   United States of America
                         "Free Software For The Rest Of Us."

  ide.diffs
7K Download

2. RSH - redirect output problem

3. Gravity, charge & magnetism are nothing but phase relationships: type "phase coherence" into Google.

4. The pkg-repository - Solaris equivalent of rpm

5. Add a module into existing Apache build?

6. Sending mails with a self-written program?

7. Adding custom module to Apache build

8. Imake template files?

9. Does apache has search module built in???

10. Apache 1.3.24 + mod_perl 1.26 + ipv6 patch build fails

11. Problem building an Apache module in C++

12. Building Apache Install to include DSO Modules??

13. What's 'side effects' of Ksh built-ins?