On 27/04/07, David Wortham <[EMAIL PROTECTED]> wrote:
I ran into a weird issue:
   My module is primarily access-based, but I do have a some other types of
hooks (a few content handlers and an output filter).

My access_checker hook function seems to work fine except when, in one
particular case, I need to respond to a specific access-condition with a
content handler.

That is to say, the possible values for access are {A, B, C, and D}.  If the
access for a particular request is "C", I need to call a content handler
function that should only run when access is "C" (and in no other case).

My assumption was that if I returned OK from the access_checker function
(which was registered with "ap_hook_access_checker(access_checker, ...)"),
that the request would be finished, wrapped up and Apache would not pass it
along the hook/handler chain.  This, apparently, is not the case (as far as
I can tell in my recent tests).

Return DONE instead of OK if your access handler has formatted a
complete response for the request.

My content-handler just injects strings directly to the response then should
direct Apache to finish up the request (like returning OK from within a
content-handler function).

My ideal situation would be to register a content-handler function only when
access-condition "C" occurs and have that content-handler serve all of the
content.

I am currently looking at this page to see what options are possible:
http://httpd.apache.org/docs/2.0/developer/hooks.html

My questions are:
- is there a way to register a handler hook from within my access_checker
function?

If you are talking about hooking a response handler, simply set
request_rec->handler to some value and then have your later response
handler you already hooked check for that value and behave differently
as a result.

- is it possible to pass meta-data around in the request_rec?  (Is this
considered bad module-programming?)

What do you mean by meta-data? One can store strings in
request_rec->notes which can then be used by later phases.
Alternatively you can store an object against
request_rec->request_config and again use it in a later phase.

- is my only viable option to run access checks both during the
access_checker phase and during the content-handler phase (and hope that my
"Access C" content handler is the first one called)?

Huh. Lost me a bit on that one but I don't think you need to run it
twice as there are means of carrying state forward as described above.

Graham

Any other suggestions for how to deal with this situation or for example
code that deals with this?

Thanks,
Dave
--
David Wortham
Senior Web Applications Developer
Unspam Technologies, Inc.
1901 Prospector Dr. #30
Park City, UT 84060
(435) 513-0672

Reply via email to