mirror of
https://github.com/django/daphne.git
synced 2025-04-22 09:42:07 +03:00
Make session decorator work right with ?session_key=
This commit is contained in:
parent
a0830f88f7
commit
29eb75326f
|
@ -47,12 +47,14 @@ def http_session(func):
|
|||
@functools.wraps(func)
|
||||
def inner(*args, **kwargs):
|
||||
if "COOKIES" not in kwargs and "GET" not in kwargs:
|
||||
print kwargs
|
||||
raise ValueError("No COOKIES or GET sent to consumer; this decorator can only be used on messages containing at least one.")
|
||||
# Make sure there's a session key
|
||||
session_key = None
|
||||
if "GET" in kwargs:
|
||||
session_key = kwargs['GET'].get("session_key")
|
||||
try:
|
||||
session_key = kwargs['GET'].get("session_key", [])[0]
|
||||
except IndexError:
|
||||
pass
|
||||
if "COOKIES" in kwargs and session_key is None:
|
||||
session_key = kwargs['COOKIES'].get(settings.SESSION_COOKIE_NAME)
|
||||
# Make a session storage
|
||||
|
|
Loading…
Reference in New Issue
Block a user