Exemple #1
0
    def _check_version(self):
        sec_websocket_version_header = 'sec-websocket-version'
        version = get_mandatory_header(self._request, sec_websocket_version_header)
        if version == _VERSION_LATEST_STRING:
            return _VERSION_LATEST

        if version.find(',') >= 0:
            raise HandshakeException(
                'Multiple versions (%r) are not allowed for header %s' %
                (version, sec_websocket_version_header),
                status=common.HTTP_STATUS_BAD_REQUEST)
        raise VersionException('Unsupported version %r for header %s' %
                               (version, sec_websocket_version_header),
                               supported_versions=', '.join(
                                   map(str, _SUPPORTED_VERSIONS)))
Exemple #2
0
    def _check_version(self):
        version = get_mandatory_header(self._request,
                                       common.SEC_WEBSOCKET_VERSION_HEADER)
        if version == _VERSION_HYBI08_STRING:
            return _VERSION_HYBI08
        if version == _VERSION_LATEST_STRING:
            return _VERSION_LATEST

        if version.find(',') >= 0:
            raise HandshakeException(
                'Multiple versions (%r) are not allowed for header %s' %
                (version, common.SEC_WEBSOCKET_VERSION_HEADER),
                status=common.HTTP_STATUS_BAD_REQUEST)
        raise VersionException('Unsupported version %r for header %s' %
                               (version, common.SEC_WEBSOCKET_VERSION_HEADER),
                               supported_versions=', '.join(
                                   map(str, _SUPPORTED_VERSIONS)))