Dear John,
filters allow application developers to decide, how to handle incoming
requests in application specific ways, and the needs differ certainly.
One can modify the filter that jeff posted slightly to omit the checking
overhead by adding the default extension based on a dot in the path as
well. I would actually prefer a file-checking variant, since when an
default extension is added without checking, one is loosing the ability
to download e.g. uploaded files without extensions, leading to probably
confusing error messages.
Applications like e.g. OpenACS have quite a complex request processor,
that i would like to shrink down (handling .tcl, .adp and .vuh (virtual
url handlers per directory, somewhat similar to unknown handlers in
tcl)), but such a simple handler as you suggested won't help here much.
Actually the content negotiation of Apache distinguishes between
- mime extensions (e.g. .html)
- language extensions (e.g. .en), and
- encoding extensions (e.g. .gz).
which can be provided in any order (e.g. foo.html.gz.en or foo.en.gz.html).
All this can be scripted in NaviServer, and i am pretty sure, that works
in apache only
via multiple check operations in the file system (for the various orders
that are supported).
But via googling for MultiView, one finds quickly many warnings about
surprising results
etc., preferring sometimes 404-messages instead of running unwanted
scripts, etc.
Another option for handling such situations could be a script-able unknown
handler for NaviServer, somewhat similar to the directory handler
_ns_dirlist, but i am
as well not sure, whether this would be a big advantage over the filter,
since one has
to trigger finally as well something like "file not found" in some
situations (similar to the
return codes of filters)
-g
Am 11.07.14 19:30, schrieb John Buckman:
On Jul 9, 2014, at 3:00 PM, Jeff Rogers <dv...@diphi.com
<mailto:dv...@diphi.com>> wrote:
There's no builtin way I know of to define a default extension. I would
do this with a preauth filter, something like this:
The preauth filter is a nice way to do it, albeit with a bit of file
existence checking overhead for every request that I'd prefer avoid.
The way my C code worked (see previous msg) was to look to see if the
request url has no extension, and no trailing / on it either, and then
to append .adp in that case. That has the advantage of being very low
overhead.
As you noted, Apache has this with MultiViews, and I use that feature
extensively on Magnatune.com <http://Magnatune.com> so that URLs look
nice and clean, ie: http://magnatune.com/artists/linda_wood
So yes, I'd vote for this to be a config level feature, since it's
already in Apache that way.
Looking at request.c it looks to me like the action happens in the
"SetUrl" function.
Specifically, there already is logic in here to deal with trailing
slashes, so a default filename extension feature would slot in well at
this point:
/*
* Append a trailing slash to the normalized URL if the original URL
* ended in slash that wasn't also the leading slash.
*/
while (*url == '/') {
++url;
}
if (*url != '\0' && url[strlen(url) - 1] == '/') {
Ns_DStringAppend(&ds2, "/");
}
/*
john - check to see if a default_extension has been set in the config
file, and if so, append it now if appropriate.
*/
request->url = ns_strdup(ds2.string);
Ns_DStringFree(&ds2);
------------------------------------------------------------------------------
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel