Prepare for solving https://github.com/kanaka/websockify/issues/71:

Rename self.client to self.request, since this is what standard
SocketServer request handlers are using.
Prepare for fixing https://github.com/kanaka/websockify/issues/71:
Move around functions and methods, so that connection-related and
server-related stuff are close together.

This patch just moves things around - it does not change anything at
all. This can be verified with:

git diff websocket.py | grep ^- | cut -c 2- | sort > removed
git diff websocket.py | grep ^+ | cut -c 2- | sort > added
diff -u removed added
Prepare for fixing https://github.com/kanaka/websockify/issues/71:

* Move traffic_legend.

* Since websocket.WebSocketServer.socket is static, don't call it with
  self.socket.
Try to solve https://github.com/kanaka/websockify/issues/71 by
refactoring. Basically, we are dividing WebSocketServer into two
classes: One request handler following the SocketServer Requesthandler
API, and one optional server engine. The standard Python SocketServer
engine can also be used.

websocketproxy.py has been updated to match the API change. I've also
added a new option --libserver in order to use the Python built in
server instead.

I've done a lot of testing with the new code. This includes: verbose,
daemon, run-once, timeout, idle-timeout, ssl, web, libserver. I've
tested both Python 2 and 3. I've also tested websocket.py in another
external service.

Code details follows:

* The new request handler class is called WebSocketRequestHandler,
  inheriting SimpleHTTPRequestHandler.

* The service engine is called WebSocketServer, just like before.

* do_websocket_handshake: Using send_header() etc, instead of manually
  sending HTTP response.

* A new method called handle_websocket() upgrades the connection to
  WebSocket, if requested. Otherwise, it returns False. A typical
  application use is:

    def do_GET(self):
        if not self.handle_websocket():
	   # handle normal requests

* new_client has been renamed to new_websocket_client, in order to
  have a better name in the SocketServer/HTTPServer request handler
  hierarchy.

* Note that in the request handler, configuration variables must be
  provided by the "server" object, ie self.server.target_host.
Fix error with modern Python 2.X versions:

TypeError: exceptions must be old-style classes or derived from
BaseException, not str

Thus, we are not allowed to raise a string. Raise Exception instead.
Renamed CustomProxyServer to WebSocketProxy; this was the earlier name.

Also, call the server instance "server", not "httpd", even when using
LibProxyServer.
Corrected last commit.
Merge remote branch 'upstream/master'
Merge branch 'master' of github.com:astrand/websockify
Rename self.client to self.request, ie adapt to:

>commit b9e1295f7afa34a4c69618609e053af154e477d7
>    Prepare for solving https://github.com/kanaka/websockify/issues/71:
>
>    Rename self.client to self.request, since this is what standard
>    SocketServer request handlers are using.
Make echo.py and load.py work again, after the refactoring of
websocket.py:

* With echo.py, which doesn't need any server configuration, we can
  just switch over our application class to inherit from
  WebSocketRequestHandler instead of WebSocketServer. Also, need to
  use the new method name new_websocket_client.

* With load.py, since we have the "delay" configuration, we need both
  a server class and a request handler.

Note that for both tests, I've removed the raising of
self.EClose(closed). This is incorrect. First of all, it's described
as "An exception before the WebSocket connection was established", so
not suitable for our case. Second, it will cause send_close to be
called twice. Finally, self.EClose is now in the WebSocketServer
class, and not a member of the request handler.
Removed unused import of SimpleHTTPRequestHandler.
Move WebSocketProxy class so that it is defined after the
requesthandler. Removed comments about above/below which does not make
sense any longer. No functional changes.
Let our ProxyRequestHandler be default. This allows you to inherit
from WebSocketProxy without having to specify handler class.
Improved class documentation.
Fix Python3 compatibility when using --libserver.
Added temp dir for unit test data and cleanup

Unit test data will now go to a temporary dir that will be deleted
once the test completes. The unit tests also setup a logger which
will persist so that it can be inspected once tests complete.

Also fixes a bug where instance var is missing from decode_hybi()

Co-authored-by: natsume.takashi@lab.ntt.co.jp
Merge pull request #105 from dosaboy/topic/unit-test-cleanup

Added temp dir for unit test data and cleanup
Clarify ssl module build for old python versions.
Merge commit '2d078e8cd83735dad7d98fadcece652d93e2a037'

* commit '2d078e8cd83735dad7d98fadcece652d93e2a037':
  correctly include include directory in egg.