Lawouach/WebSocket-for-Python — pull request #27 by chadselph (2012-02-24 09:57:19+00:00)
Title: Fix SSL Clients

I found a bug in using clients with wss:// urls where the SSL connection would always get immediately closed.

I figured out that the WebSocket.sender had been set to socket.sendall before the socket had been upgraded to an SSL wrapped socket. I also changed the default port to be 443 on an wss connection.

Also included are some other minor fixes; I didn't mean to include them but they're minor enough that I didn't fix it.

One is a fix for gevent servers with the wsgi middleware. `gevent.pywgsi` was choking on

```
(environ.get('upgrade.socket',
environ.get('wsgi.input')._sock)
```

because it's wsgi.input doesn't have a `._sock`. Since it's going to use `upgrade.socket` anyway and disregard `wsgi.input`, I don't check for `wsgi.input` unless there is no `upgrade.socket`. If a WSGI app doesn't have `upgrade.socket` and `wsgi.input` doesn't have a `._sock` it will behave exactly as before (namely, throw an `AttributeError`). This probably isn't the desired behavior but it was out of the scope for my fix.

Finally, there's an included commit which I have a separate pull request for.