Valery Brasseur writes:
> I use the W3 lib in NON_PREMPTIVE mode and I need to temporarily suspend a
> request, while waiting some user information ( like a filename in a dialog
> box )n, but I haven't seen anuthing for this in the HTRequest functions.
> How can I do that ?
It depends on what platform you're on and whether your user input function is
modal or non-modal. Normally it is only a problem if you are using non-modal
input functions where the library can continue a request while waiting for
user input. Modal user input functions (via stdin, for example) will
automatically block the current process and all requests will stop immediately.
If you want to have a non-modal user input function then the Library does
support that in that the user event handler is of exactly the same form as any
or the other protocol event handlers (HTEventHandler) but it does probably
impose some restrictions on how you implement it. For example, all the
protocol modules in the Library are implemented using state machines so that
we can keep state of where we are.
In case you are using non-modal user input then regardless of the platform
you're are using, the easiest way to suspend a current download is simply to
unregister it so that it isn't registered in the bit array that is parsed to
the select() call, be it the synchronous or the asynchonous version.
You can unregister an event by calling the function
extern int HTEvent_UnRegister (SOCKET, SockOps);
In the event API there is actually the notion of setting and getting the
"priority" of a request. However, this is not yet implemented in the event
loop but eventually this will be the way to do it. Even though the
implementation is not quite there, the API is actually in place. You can set
the start priority of a request in the Request object (HTReq.html):
extern HTPriority HTRequest_priority (HTRequest * request);
extern BOOL HTRequest_setPriority (HTRequest * request, HTPriority priority);
Or you can change the priority while the request is active by using the Net
object (HTNethtml):
extern HTPriority HTNet_priority (HTNet * net);
extern BOOL HTNet_setPriority (HTNet * net, HTPriority priority);
--
Henrik Frystyk Nielsen, <frystyk@w3.org>
World-Wide Web Consortium, MIT/LCS NE43-356
545 Technology Square, Cambridge MA 02139, USA