Lawouach/WebSocket-for-Python — pull request #53 by EliAndrewC (2012-08-08 22:52:18+00:00)
Title: Minor fix which turns an unintentional and confusing error message into the intended error message

WebSocketTool.upgrade is supposed to raise a HandshakeError with the message "Header %s is not defined" if either the "Upgrade" or "Connection" header is missing.

However, the expression on line 126 of cherrypyserver.py:

request.headers.get(key).lower()

raises an AttributeError with the message "'NoneType' object has no attribute 'lower'" if one of those headers is missing, which prevents the intended error message from ever being displayed.

This commit fixes this problem by replacing get(key) with get(key, '') since the empty string evaluates as false.