mirror of
https://github.com/django/daphne.git
synced 2025-04-21 17:22:03 +03:00
Lowercase request GET/POST etc.
This commit is contained in:
parent
70caf7d171
commit
2dd7f589eb
|
@ -26,17 +26,17 @@ def http_session(func):
|
|||
"""
|
||||
@functools.wraps(func)
|
||||
def inner(message, *args, **kwargs):
|
||||
if "COOKIES" not in message.content and "GET" not in message.content:
|
||||
raise ValueError("No COOKIES or GET sent to consumer; this decorator can only be used on messages containing at least one.")
|
||||
if "cookies" not in message.content and "get" not in message.content:
|
||||
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 message.content:
|
||||
if "get" in message.content:
|
||||
try:
|
||||
session_key = message.content['GET'].get("session_key", [])[0]
|
||||
session_key = message.content['get'].get("session_key", [])[0]
|
||||
except IndexError:
|
||||
pass
|
||||
if "COOKIES" in message.content and session_key is None:
|
||||
session_key = message.content['COOKIES'].get(settings.SESSION_COOKIE_NAME)
|
||||
if "cookies" in message.content and session_key is None:
|
||||
session_key = message.content['cookies'].get(settings.SESSION_COOKIE_NAME)
|
||||
# Make a session storage
|
||||
if session_key:
|
||||
session_engine = import_module(settings.SESSION_ENGINE)
|
||||
|
|
|
@ -10,10 +10,10 @@ def encode_request(request):
|
|||
"""
|
||||
# TODO: More stuff
|
||||
value = {
|
||||
"GET": dict(request.GET.lists()),
|
||||
"POST": dict(request.POST.lists()),
|
||||
"COOKIES": request.COOKIES,
|
||||
"META": {k: v for k, v in request.META.items() if not k.startswith("wsgi")},
|
||||
"get": dict(request.GET.lists()),
|
||||
"post": dict(request.POST.lists()),
|
||||
"cookies": request.COOKIES,
|
||||
"meta": {k: v for k, v in request.META.items() if not k.startswith("wsgi")},
|
||||
"path": request.path,
|
||||
"path_info": request.path_info,
|
||||
"method": request.method,
|
||||
|
@ -27,10 +27,10 @@ def decode_request(value):
|
|||
Decodes a request JSONish value to a HttpRequest object.
|
||||
"""
|
||||
request = HttpRequest()
|
||||
request.GET = CustomQueryDict(value['GET'])
|
||||
request.POST = CustomQueryDict(value['POST'])
|
||||
request.COOKIES = value['COOKIES']
|
||||
request.META = value['META']
|
||||
request.GET = CustomQueryDict(value['get'])
|
||||
request.POST = CustomQueryDict(value['post'])
|
||||
request.COOKIES = value['cookies']
|
||||
request.META = value['meta']
|
||||
request.path = value['path']
|
||||
request.method = value['method']
|
||||
request.path_info = value['path_info']
|
||||
|
|
|
@ -34,10 +34,10 @@ Standard channel name is ``http.request``.
|
|||
|
||||
Contains the following keys:
|
||||
|
||||
* GET: List of (key, value) tuples of GET variables (keys and values are strings)
|
||||
* POST: List of (key, value) tuples of POST variables (keys and values are strings)
|
||||
* COOKIES: Dict of cookies as {cookie_name: cookie_value} (names and values are strings)
|
||||
* META: Dict of HTTP headers and info as defined in the Django Request docs (names and values are strings)
|
||||
* get: List of (key, value) tuples of GET variables (keys and values are strings)
|
||||
* post: List of (key, value) tuples of POST variables (keys and values are strings)
|
||||
* cookies: Dict of cookies as {cookie_name: cookie_value} (names and values are strings)
|
||||
* meta: Dict of HTTP headers and info as defined in the Django Request docs (names and values are strings)
|
||||
* path: String, full path to the requested page, without query string or domain
|
||||
* path_info: String, like ``path`` but without any script prefix. Often just ``path``.
|
||||
* method: String, upper-cased HTTP method
|
||||
|
|
Loading…
Reference in New Issue
Block a user