John Peacock wrote:
I was thinking that it should be made clear that the _pre and _post hooks are slightly different than the cases that "FIRST, MIDDLE and LAST" variants are likely to cover.

Based on the deafening silence that met this proposal, I'm going to implement it as such (I've already worked on the queue_pre/queue_post variants).


For example (this is open for discussion):

====================================

[hook]_pre - fires immediately before [hook] and can be used to avoid running [hook] entirely. Only return values of OK, DONE, and DECLINED are acceptable. OK means fire [hook] and DONE means skip the [hook] processing entirely. DECLINED has its ordinary meaning in that multiple hooks can return it and if none of them returns OK, then the normal [hook] processing continues. NOTE that DONE may be meaningless for certain hooks, e.g. DATA *must* be processed.

[hook]_post - fires immediately after [hook] iff [hook] returned either OK or DECLINED (but not any variant on DENY). Return values of OK, DECLINED, or DENY (plus variants) are acceptable. If DENY (or a variant) is returned, then this will be promoted to returning this value from [hook] (e.g. block viruses in data_post).

Both _pre and _post variants *should not* perform the actions normally performed by the associated hook. That includes (but is not limited to):

- reading from the remote client
- responding to the remote client

Both _pre and _post hooks *may* modify the in-process transaction object (e.g. adding headers).

====================================

The _pre and _post hooks will normally be implemented inside the sub() for the associated hook, so that the current flow control will not be altered (e.g. data calls data_pre, does its shtick, then calls queue, and finally calls data_post).


I realize that last paragraph is wrong.  Here it is rewritten for accuracy:

The _pre and _post hooks will normally be implemented inside the sub() for the associated hook, so that the current flow control will not be altered (e.g. data calls data_pre, does its shtick, then calls data_post, and finally calls queue).

John

Reply via email to