> So how do you hook your HTTP channel into things, exactly? > I have a custom handler class HttpxHandler. At the startup, I replace the HttpsHandler with this custom handler and pass the original HttpsHandler to it.
The HttpxHandler class implements all the interfaces just like HttpHandler class. Except for NewProxiedChannel(...) method, almost all the methods invoke the corresponding methods of the original HttpsHandler. (The concept is inspired by the Firekeeper project.) The NewProxiedChannel(..) method encrypts the request and returns an instance of the custom channel class HttpxChannel. This class implements all the interfaces just like HttpChannel (again by invoking the corresponding HttpChannel methods for almost all the methods except for AsyncOpen(...)). The AsyncOpen(...) method instantiates a custom listener class HttpxListener and passes it as the listener to the original HTTP channel's AsyncOpen(...) method. The HttpxListener does the response decryption in OnDataAvailable(...) method and passes the decrypted response to the original listener. As you can see here, the encryption happens when a new channel is opened. For some reason, my understanding was that a channel really corresponds to a request. So for every request, there will be a new channel and obviously that does not seem to be the case. I really appreciate your help ! Thanks, Maya. _______________________________________________ dev-tech-network mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-network
