Anant Narayanan wrote: > Onto the real question: Is it possible for me to generate some HTML > +JavaScript on-the-fly and somehow put it into a "channel" and return > it from newChannel() so Mozilla can display that page for me?
Absolutely. You have two basic options. The first one, possibly simpler to code but with worse behavior is to get all the data in newChannel(), stick it into an input stream (e.g. write it into a pipe or use a string input stream), create a stream channel (see <http://lxr.mozilla.org/seamonkey/search?string=/network/input-stream-cha> for a JS example in the microsummary service, and see <http://lxr.mozilla.org/seamonkey/search?string=NS_NewInputStreamChann> for C++ examples), and return that channel. The bad behavior is having to block the calling thread (so the UI thread) while you do your socket access. This is also suboptimal because you'll make the connection to the server even if the caller doesn't actually want to do so. A better approach is to create your own implementation of nsIChannel/nsIRequest. Return your object, then when the consumer calls AsyncOpen actually make the connection to the server... and wait for the data. When you get a response, create whatever HTML you want to create, stick it in an input stream, and make the requisite OnStartRequest/OnDataAvailable/OnStopRequest calls. -Boris _______________________________________________ dev-tech-network mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-network
