Mailing List Archive

Relative URLs with imagemap
Apparently can't be done with the current imagemap program. The
behavior I described as a bug in Shambhala exists in 0.6.5 as
well. It looks like imagemap does not grok a map file containing
a URL without leading slash.

This could probably be fixed relatively easy.... As I look at this
it seems that we need a mod_imagemap for Shambhala. Are there some
basics that could be shared with the group regarding the module
interface? How do we currently determine when to run the code
in a module? ie mod_cgi

I would probably quickly be over my head with mod_imagemap, so I
think I will give the mod_logpipe a try first.

-Randy
Re: Relative URLs with imagemap [ In reply to ]
X-Uri: http://www.zyzzyva.com/
Date: Sun, 02 Jul 1995 12:03:57 -0500
From: Randy Terbush <randy@zyzzyva.com>

Apparently can't be done with the current imagemap program. The
behavior I described as a bug in Shambhala exists in 0.6.5 as
well. It looks like imagemap does not grok a map file containing
a URL without leading slash.

Correct. Known problem, which could be fixed by fixing the imagemap
program. (It would have to take PATH_INFO as the URI of the map
itself, interpreting relative URIs in the map file itself as relative
to that, and concocting the full local URI itself; eminently doable).

This could probably be fixed relatively easy.... As I look at this
it seems that we need a mod_imagemap for Shambhala. Are there some
basics that could be shared with the group regarding the module
interface? How do we currently determine when to run the code
in a module? ie mod_cgi

I really ought to start writing it up... here are the basics:

Shambhala breaks down request handling into a series of steps, more or
less the same way the Netscape Server API does (although Shambhala has
a few more stages than NetSite does, as hooks for stuff I thought
might be useful in the future). These are:

*) URI -> Filename translation
*) Auth ID checking [is the user who they say they are?]
*) Auth access checking [is the user authorized *here*?]
*) Access checking other than auth
*) Determining MIME type of the object requested
*) "Fixups" --- there aren't any of these yet, but the phase is
intended as a hook for stuff like SetEnv and the like, which don't
really fit well elsewhere.
*) Actually sending stuff back to the client. [.This is a special
case; the core code actually does a dispatch on MIME type, though
as of 0.4.5 modules can declare handlers for "*/*", which are
invoked in order of module priority if no handler for the specific
type exists, or if all the type-specific handlers decline to handle
the request --- this is how XBITHACK works].
*) Logging the request

The module structure is actually, for the most part, just a dispatch
table, with one entry for each phase, which is either NULL or a
handler for the phase. The handlers, if they exist, are functions of
one argument (a request_rec structure) which all return 'int' --- the
integer they return is either OK (i.e., "I handled it"), DECLINED
(in which case the server core acts as if the handler didn't exist for
purposes of this request, and looks for another), or an error code, in
which case the request is aborted, and the ErrorDocument machinery
comes into play.

Additionally, there are two subsidiary dispatch tables in the module
structure, one for config-file commands which the module defines
(details put off to another note), and one for MIME types for which
the module can generate a reponse. (There are also functions which
handle reinitialization at server restart, and which deal with the
module's private config data structures, if it has any).

Response handlers have a few more options than handlers for the other
phases; in addition to declining, or returning an error code (before
sending anything --- we don't want two HTTP headers in one response!),
they can use send_http_header(), rprintf() and the like to actually
send a response, or they can handle redirects in one of two ways:

*) set "location" in the out_headers of the request_rec, and
then return REDIRECT (which is how extrenal redirects are
handled).

*) invoke the function "internal_redirect" with some local URI,
and then return OK (which is how internal redirects, e.g., to
DirectoryIndex files, or from CGI scripts, are handled, as well
as how ErrorDocument works internally).

These last options are presumably what the response handler in an
imagemap module would do in the typical case.

That's still too sketchy, but it should help you find your bearings, I
hope.

I would probably quickly be over my head with mod_imagemap, so I
think I will give the mod_logpipe a try first.

OK --- the tricky part is making sure that it cleans up after itself
on server restart, i.e., at the time that the config resource pool is
cleared. One of my TODO list items is to make it possible for you to
do this using your own cleanup function; this would make it possible
for you to just use popen(), registering the pclose() as a cleanup on
the config resource pool. That'll hopefully be done this
weekend.

FWIW, alloc.c does provide a spawn_child routine which arranges for
pipes either into or out of the child process (there are FILE **
arguments which are either NULL if you don't want to pipe data in that
direction, or get set to FILE *s which have the right end of the pipe
if you do), and arranges for the SIGTERM/pause/SIGKILL routine to
ditch the process when the relevant resource pool is cleared. If you
want to try using this, the best code to copy here would probably be
the code that handles <!--#exec cmd="..."--> directives (the function
include_cmd in mod_include.c), though you'll want to set up to pipe
into the process, rather than out of it, meaning the last two
arguments to spawn_child will be different.

(If you use spawn_child, then the child will still receive a SIGHUP as
the root server process blows away all its server children, before the
SIGTERM/pause/SIGKILL routine; if this isn't desirable, just ignoring
SIGHUP before the exec() should shield your child from it. If you use
popen(), once the general cleanup interface is there, then you still
get the SIGHUP, but after that you get whatever behavior pclose()
gives you --- which may mean waiting indefinitely if the child refuses
to die).

I hope this isn't all too obscure, but expect otherwise. (Sigh...).
Let me know what needs to be expanded on...

rst
Re: Relative URLs with imagemap [ In reply to ]
> That's still too sketchy, but it should help you find your bearings, I
> hope.
>
> I hope this isn't all too obscure, but expect otherwise. (Sigh...).
> Let me know what needs to be expanded on...
>
> rst
>

OK. Getting my bearings.... I have the makings of a mod_imap
created that doesn't crash the server... However, it does not
seem to be getting the imap_handler in front of the server.

I've defined:

#define IMAP_MAGIC_TYPE "application/x-httpd-imap"

handler_rec imap_handlers[] = {
{ IMAP_MAGIC_TYPE, imap_handler },
{ NULL }
};

module imap_module = {
STANDARD_MODULE_STUFF,
NULL, /* initializer */
NULL, /* dir config creater */
NULL, /* dir merger --- default is to override */
NULL, /* server config */
NULL, /* merge server config */
NULL, /* command table */
imap_handlers, /* handlers */
NULL, /* filename translation */
NULL, /* check_user_id */
NULL, /* check auth */
NULL, /* check access */
NULL, /* type_checker */
NULL, /* fixups */
NULL /* logger */
};

And have an 'AddType application/x-httpd-imap imap' in srm.conf.

When I select a URL with a *.imap HREF, the browser goes to save-as
mode, and my imap_handler() appears to not be called.

Any hints? I'd be happy to send along the module if you have time
to look at it.

-Randy
Re: Relative URLs with imagemap [ In reply to ]
On Sun, 2 Jul 1995, Robert S. Thau wrote:
> Apparently can't be done with the current imagemap program. The
> behavior I described as a bug in Shambhala exists in 0.6.5 as
> well. It looks like imagemap does not grok a map file containing
> a URL without leading slash.
>
> Correct. Known problem, which could be fixed by fixing the imagemap
> program. (It would have to take PATH_INFO as the URI of the map
> itself, interpreting relative URIs in the map file itself as relative
> to that, and concocting the full local URI itself; eminently doable).

And done :) Here is my "imagemap2", which allows

1) relative URL's in the mapfile
2) is invoked as a shell in a map file marked executable, rather
than directly by the web server.

Check out the other attachment, a sample .map file which you would find
at http://www.volvocars.com/Dealers/. I'm sure the code could use some
cleaning - it would be a good test of how easy it is to plug CGI
functionality in as a module. I'm under the gun for a couple of projects
here so I can't devote time anytime soon to this, but there it is.

Rob, you should turn that module spec into a web page on apache.org, even
if it's not linked in anywhere....

Brian


--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
brian@organic.com brian@hyperreal.com http://www.[hyperreal,organic].com/
Re: Relative URLs with imagemap [ In reply to ]
Date: Sun, 02 Jul 1995 17:48:32 -0500
From: Randy Terbush <randy@zyzzyva.com>

And have an 'AddType application/x-httpd-imap imap' in srm.conf.

When I select a URL with a *.imap HREF, the browser goes to save-as
mode, and my imap_handler() appears to not be called.

It sounds like it's not finding the handler.

Hmmm... I take it you also added your module to the prelinked_modules
list in modules.c, so the server core can find it. (If not, then
that's the problem). The best way to try to figure out what's going
on might be to put a breakpoint on invoke_handler(), and see what it
does and where it gets lost.

(BTW, for anyone else who wants to start playing with this stuff, I
might as well mention that the easiest way to do this sort of thing is
to do a "gdb httpd", and then run it with the -X option. That makes
it start up as it would normally, except that if it's set for
standalone operation, then it skips the forks, and you wind up with
the child_main loop running in the single process that the debugger
started. You can then connect to it with the client of your choice,
setting breakpoints in the server itself and all that good stuff.

One caveat: if you try this, you'll find that the process sends
itself, and the other nonexistent processes in its group, a SIGHUP at
the start of standalone_main(); just continue through this (SIGHUP is
ignored at that point anyway), and you'll be fine).

rst
Re: Relative URLs with imagemap [ In reply to ]
Date: Sun, 2 Jul 1995 16:56:20 -0700 (PDT)
From: Brian Behlendorf <brian@organic.com>

Rob, you should turn that module spec into a web page on apache.org, even
if it's not linked in anywhere....

Hmmm... I've been thinking of turning it into a paper for WWW4 (I'd
have to flesh it out a bit). But I guess it's the same difference,
since they do seem to want HTML. (Hmmm... just one long HTML file, or
what?)

rst