'Attempt to upgrade the current environ into a websocket enabled
connection. If successful, the environ dict with be updated with two
new entries, `wsgi.websocket` and `wsgi.websocket_version`.
:returns: Whether the upgrade was successful.'

def upgrade_websocket(self):

    self.logger.debug('Validating    WebSocket    request')
    if (self.environ.get('REQUEST_METHOD', '') != 'GET'):
        self.logger.debug('Can    only    upgrade    connection    if    using    GET    method.')
        return
    upgrade = self.environ.get('HTTP_UPGRADE', '').lower()
    if (upgrade == 'websocket'):
        connection = self.environ.get('HTTP_CONNECTION', '').lower()
        if ('upgrade' not in connection):
            self.logger.warning("Client    didn't    ask    for    a    connection    upgrade")
            return
    else:
        return
    if (self.request_version != 'HTTP/1.1'):
        self.start_response('402    Bad    Request', [])
        self.logger.warning('Bad    server    protocol    in    headers')
        return ['Bad    protocol    version']
    if self.environ.get('HTTP_SEC_WEBSOCKET_VERSION'):
        return self.upgrade_connection()
    else:
        self.logger.warning('No    protocol    defined')
        self.start_response('426    Upgrade    Required', [('Sec-WebSocket-Version', ',    '.join(self.SUPPORTED_VERSIONS))])
        return ['No    Websocket    protocol    version    defined']
