My favourite is proposal 2. However, I do not know if I could use this way to establish a WebSockets connection, but I have to examine that in small steps. The next step in thinking through the stuff will be to keep the TCP connection open after the request and handle it over to some custom class (that finishes the handshake on WebSockets level).
What do you think about that? I need your help. Is an upgrade from HttpClient 3.0 to 3.1 a viable option?Sometimes Mozilla Firefox tries to "CONNECT":
CONNECT echo.websocket.org:80 HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:12.0) Gecko/20100101 Firefox/12.0
Proxy-Connection: keep-alive
Host: echo.websocket.org
If the client is configured to use a proxy when using the WebSocket Protocol to connect to host /host/ and port /port/, then the client SHOULD connect to that proxy and ask it to open a TCP connection to the host given by /host/ and the port given by /port/.
Anyway, regarding the issue you have pointed, the "problem" happens (the channel "browser<->ZAP" is closed) when the stream (httpIn) is closed in the method ProxyThread.disconnect() that is executed after the thread WebSocketsThread is started.
Probably because of (from the documentation of the method java.io.Closeable.close()):
"Closes this stream and releases any system resources associated with it."
If no one comes up with a solution or advice, I am forced to continue with solution#3. Contact me if you want to take a look at the source code.
Best wishes,
Robert