Mailing List Archive

How to get files in svn directory processed by another mod
I am developing a mod to display (translated) markdown. It seems to be
working for an independent directory, but when I click on a file in an
svn directory, I get a standard browser download/open dialog. (We have
a .md file in svn directories which is a README type file to help users
understand what that directory/repository is to be used for. The file
is in the actual directory, as opposed to under svn control)

It feels like the mod(s) which handle svn is not letting my mod_xxx deal
with the file.

I have tried setting the arg(s) to ap_hook_handler to APR_HOOK_MIDDLE,
APR_HOOK_LAST, and telling it to execute before mod_dav.c:

static const char *const following_mods[] = {"mod_dav.c", NULL};
ap_hook_handler(tst_handler, NULL, following_mods, APR_HOOK_MIDDLE);

Thanks for any pointers,

Gary

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: How to get files in svn directory processed by another mod [ In reply to ]
On Thu, Jul 28, 2022 at 3:58 PM Gary Aitken <apache@dreamchaser.org> wrote:
>
> I am developing a mod to display (translated) markdown. It seems to be
> working for an independent directory, but when I click on a file in an
> svn directory, I get a standard browser download/open dialog. (We have
> a .md file in svn directories which is a README type file to help users
> understand what that directory/repository is to be used for. The file
> is in the actual directory, as opposed to under svn control)
>
> It feels like the mod(s) which handle svn is not letting my mod_xxx deal
> with the file.
>
> I have tried setting the arg(s) to ap_hook_handler to APR_HOOK_MIDDLE,
> APR_HOOK_LAST, and telling it to execute before mod_dav.c:
>
> static const char *const following_mods[] = {"mod_dav.c", NULL};
> ap_hook_handler(tst_handler, NULL, following_mods, APR_HOOK_MIDDLE);

I think you want to write an output filter, not a handler. But maybe
it can technically work with (in place of) mod_dav, I don't know.
I don't see why your handler would be pre-empted by mod_dav if you
were APR_HOOK_MIDDLE and listed it as a successor.

Is your mod instrumented with trace?
Have you looked at mod_info output to show hook order?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: How to get files in svn directory processed by another mod [ In reply to ]
Thanks for the reply,

On 7/28/22 5:29 PM, Eric Covener wrote:
> On Thu, Jul 28, 2022 at 3:58 PM Gary Aitken <apache@dreamchaser.org> wrote:
<snip>
>> It feels like the mod(s) which handle svn is not letting my mod_xxx deal
>> with the file.
...
> Is your mod instrumented with trace?

No; I don't know what that is.
I enabled mod_status but that does not seem particularly useful at first
blush.
Is your reference to something other than http trace?
I thought that was limited to establishing whether the request was handled
or not, not how a request was handed around in the server itself.
ptr?

> Have you looked at mod_info output to show hook order?

I see the following under mod_info for Content Handlers:
-10 core.c
00 mod_passenger.c
20 mod_passenger.c
10 mod_autoindex.c
00 mod_passenger.c
10 mod_auth_openidc.c
10 mod_md.c
10 mod_dav.c
10 mod_dav_svn.c
10 mod_cgid.c
10 mod_info.c
10 mod_negotiation.c
10 mod_perl.c
10 mod_perl.c
10 mod_rewrite.c
10 mod_status.c
20 mod_dav_svn.c
20 mod_commonmark.c
20 mod_passenger.c
30 core.c

I don't understand the above output. Are the numbers on the left a
priority / ordering value to determine the call order? Are mods with
the same value called in the order listed?

Thanks for any clues,

Gary

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: How to get files in svn directory processed by another mod [ In reply to ]
On Fri, Jul 29, 2022 at 10:30 AM Gary Aitken <apache@dreamchaser.org> wrote:
>
> Thanks for the reply,
>
> On 7/28/22 5:29 PM, Eric Covener wrote:
> > On Thu, Jul 28, 2022 at 3:58 PM Gary Aitken <apache@dreamchaser.org> wrote:
> <snip>
> >> It feels like the mod(s) which handle svn is not letting my mod_xxx deal
> >> with the file.
> ...
> > Is your mod instrumented with trace?
>
> No; I don't know what that is.

I just meant adding ap_log_rerror trace output (and reviewing the
trace output of other modules)


> I enabled mod_status but that does not seem particularly useful at first
> blush.
> Is your reference to something other than http trace?
> I thought that was limited to establishing whether the request was handled
> or not, not how a request was handed around in the server itself.
> ptr?
>
> > Have you looked at mod_info output to show hook order?
>
> I see the following under mod_info for Content Handlers:
> -10 core.c
> 00 mod_passenger.c
> 20 mod_passenger.c
> 10 mod_autoindex.c
> 00 mod_passenger.c
> 10 mod_auth_openidc.c
> 10 mod_md.c
> 10 mod_dav.c
> 10 mod_dav_svn.c
> 10 mod_cgid.c
> 10 mod_info.c
> 10 mod_negotiation.c
> 10 mod_perl.c
> 10 mod_perl.c
> 10 mod_rewrite.c
> 10 mod_status.c
> 20 mod_dav_svn.c
> 20 mod_commonmark.c
> 20 mod_passenger.c
> 30 core.c
>
> I don't understand the above output. Are the numbers on the left a
> priority / ordering value to determine the call order? Are mods with
> the same value called in the order listed?

It's the order, 10 is APR_HOOK_MIDDLE. It looks like you aren't
currently APR_HOOK_MIDDLE -- If you are trying to run before and
pre-empty mod_dav/mod_dav_svn you should run as early as possible.

I don't know why they are interleaved in that output, I've never seen
that before. Maybe it is related to predecessors/successors having
precedence over APR_HOOK_* but i didn't realize that happened.
Regardless, mod_commonmark is quite late here. Any handler above it
that does not decline will stop it from running.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: How to get files in svn directory processed by another mod [ In reply to ]
Thanks for the hints/clues,

>> On 7/28/22 5:29 PM, Eric Covener wrote:
>>> On Thu, Jul 28, 2022 at 3:58 PM Gary Aitken <apache@dreamchaser.org> wrote:

>> I see the following under mod_info for Content Handlers:
>> -10 core.c
>> 00 mod_passenger.c
>> 20 mod_passenger.c
>> 10 mod_autoindex.c
>> 00 mod_passenger.c
>> 10 mod_auth_openidc.c
>> 10 mod_md.c
>> 10 mod_dav.c
>> 10 mod_dav_svn.c
>> 10 mod_cgid.c
>> 10 mod_info.c
>> 10 mod_negotiation.c
>> 10 mod_perl.c
>> 10 mod_perl.c
>> 10 mod_rewrite.c
>> 10 mod_status.c
>> 20 mod_dav_svn.c
>> 20 mod_commonmark.c
>> 20 mod_passenger.c
>> 30 core.c
>>
>> I don't understand the above output.
<snip>> It's the order, 10 is APR_HOOK_MIDDLE. It looks like you aren't
> currently APR_HOOK_MIDDLE -- If you are trying to run before and
> pre-empty mod_dav/mod_dav_svn you should run as early as possible.
>
> I don't know why they are interleaved in that output, I've never seen
> that before. Maybe it is related to predecessors/successors having
> precedence over APR_HOOK_* but i didn't realize that happened.
> Regardless, mod_commonmark is quite late here. Any handler above it
> that does not decline will stop it from running.

mod_commonmark is a relic, I didn't realize it was still in there.
mod_md is the one I'm interested in, so it does precede mod_dav
and mod_dav_svn (both occurances)

I added log_debug and the relevant configuration now looks like:
<Location /repo/td/tst.md>
LogMessage "=== /repo/td/tst.md === %{HANDLER}" hook=all
</Location>

When I set
LogLevel debug
I see the following output (cleaned up and abbreviated) when requesting
a .md file in one of the svn (/repo) directories:

1. [log_debug:info] === /repo/td/tst.md === (type_checker hook
2. [log_debug:info] === /repo/td/tst.md === md (fixups hook,
3. [log_debug:info] === /repo/td/tst.md === dav-handler (insert_filter hook,
4. [log_debug:info] === /repo/td/tst.md === dav-handler (handler hook,
5. [:debug] mod_md.c(270): md_handler handler=dav-handler filename=dav_svn:/.../repo/td/tst.md, referer: https://my-site/repo/td/
6. [log_debug:info] === /repo/td/tst.md === dav-handler (log_transaction hook,

Line 5 is the result of the following first line in my md_handler:
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "md_handler handler=%s filename=%s", r->handler?r->handler:"<null>", r->filename?r->filename:"<null>");

Line 5 from md_handler is printed after two calls to dav-handler
(insert_filter and handler).

On the call to md_handler in line 5, the handler passed in (r->handler)
is dav-handler, so md_handler ignores the call;
md_handler is never called with r->handler == "md"

Questions:

1. Why does dav-handler's handler hook get called before md's handler
(which doesn't get called at all)? Would I be correct in thinking it's
because of #3?

2. Is/can dav-handler's filter hook preventing the call to md's handler?

3. Should I be inserting a filter in front of dav's filter to preempt
dav's filter?

4. or should I be doing something in line 2, md's fixup hook? Will/can
that preclude dav's insert_filter being called? Is there a template
anywhere describing how a fixup handler should/could work if it's trying
to insure some order? The docs here:
https://httpd.apache.org/docs/2.4/developer/request.html
says

"Many modules are 'trounced' by some phase above. The fixups phase is used
by modules to 'reassert' their ownership or force the request's fields to
their appropriate values. It isn't always the cleanest mechanism, but
occasionally it's the only option."

but nothing about where / how to write such a handler to insure ordering.

4. What/why is there a call to md's fixups hook when it has no fixup hook
registered? The only hooks registered are:
ap_hook_check_config(md_hook_check_config, NULL, NULL, APR_HOOK_LAST);
ap_hook_post_config(md_post_config_handler, NULL, NULL, APR_HOOK_LAST);
ap_hook_log_transaction(md_log_handler, NULL, NULL, APR_HOOK_LAST);
ap_hook_handler(md_handler, NULL, conflicting_mods, APR_HOOK_MIDDLE);

confused, but learning things along the way...
thanks,

Gary

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org