Completely rework websocket support.

* Remove the useless "connect" thread.
* Fix semaphore leak (one was created at each iteration of the read
loop, and they were never deleted)
* Fix race condition leading to use of the SocketStreamHandle class
after deletion, using a trick similar to the one used by the soup code.
We keep a set of the "live" objects, so asynchronous callbacks  can
easily check if the object they want to use is still allocated.
* Make the code simpler by removing methods that are called only once,
turning static functions into static methods, and more.

Fixes #10758.