Re: How to stop the event loop?

At 14:06 12/14/98 -0500, Jim_Ravan@avid.com wrote:
>
>I'm trying to write a "standard" AFTER filter that I will use in lots of
>places to stop the event loop. Currently my Put code looks something like:
>
>     // Perform a ranged PUT on that anchor.
>     request = HTRequest_new();
>     HTRequest_addRange(request, "bytes", rangeStr);
>     HTRequest_addAfter(request, endRequest, NULL, NULL, HT_ALL,
>HT_FILTER_LAST, FALSE);
>
>     if (HTPutAbsolute(HTAnchor_parent(anchor), urlStr, request)) {
>          HTEventList_loop(request);
>          err = OK;
>     } else {
>          err = NO;
>     }
>
>     static int endRequest(HTRequest* req, HTResponse* res, void* param,
>int status) {
>          HTEventList_stopLoop();
>          return HT_OK;
>     }
>
>My first question is "Is this an acceptable way to stop the event loop?".
>If so, it seems that endRequest() does not handle redirections, and if one
>is in progress, this filter will stop the redirection.

If you are using the default, global AFTER filters which you get when
creating a profile calling HTAfterInit() in

	http://www.w3.org/Library/src/HTInit.html

and you don't override the global filters with local filters for any
particular request (which you haven't done here) then the default
redirection filter will handle this and issue a new request and break the
filter line so that your filter isn't called. The same is the case for
authentication, for example.

That is, the sample program

	http://www.w3.org/Library/Examples/put.c

in fact handles authentication and redirection and it has the same style of
"last filter" as you have.

Btw, you can register your after filter as a global filter which may be
easier if you are using it for all requests.

> Is this correct, and
>if so, how should the AFTER filter be coded so as to stop the event loop
>when the PUT has finished and, at the same time, handle redirections, etc?

Starting and stopping the eventloop doesn't impact which filters are
called. The thing you have to be careful about when stopping the event loop
is that all requests have terminated so that there are no ongoing requests
that suddenly are stopped because the eventloop has stopped.

You can find some more information on this at

	http://www.w3.org/Library/src/HTEvtLst.html

Henrik
--
Henrik Frystyk Nielsen,
World Wide Web Consortium
http://www.w3.org/People/Frystyk

Received on Monday, 14 December 1998 17:07:38 UTC