python 2.6 support
This commit is contained in:
@@ -30,6 +30,7 @@ import uuid
|
|||||||
import hashlib
|
import hashlib
|
||||||
import hmac
|
import hmac
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
from ._logging import *
|
from ._logging import *
|
||||||
from ._url import *
|
from ._url import *
|
||||||
@@ -148,7 +149,11 @@ def _validate(headers, key, subprotocols):
|
|||||||
|
|
||||||
value = (key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").encode('utf-8')
|
value = (key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").encode('utf-8')
|
||||||
hashed = base64encode(hashlib.sha1(value).digest()).strip().lower()
|
hashed = base64encode(hashlib.sha1(value).digest()).strip().lower()
|
||||||
success = hmac.compare_digest(hashed, result)
|
if sys.version_info[0] == 2 and sys.version_info[1] < 7:
|
||||||
|
success = (hashed == result)
|
||||||
|
else:
|
||||||
|
success = hmac.compare_digest(hashed, result)
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
return True, subproto
|
return True, subproto
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user