mirror of
https://github.com/django/daphne.git
synced 2025-07-10 16:02:18 +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)
|
@functools.wraps(func)
|
||||||
def inner(message, *args, **kwargs):
|
def inner(message, *args, **kwargs):
|
||||||
if "COOKIES" not in message.content and "GET" not in message.content:
|
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.")
|
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
|
# Make sure there's a session key
|
||||||
session_key = None
|
session_key = None
|
||||||
if "GET" in message.content:
|
if "get" in message.content:
|
||||||
try:
|
try:
|
||||||
session_key = message.content['GET'].get("session_key", [])[0]
|
session_key = message.content['get'].get("session_key", [])[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
if "COOKIES" in message.content and session_key is None:
|
if "cookies" in message.content and session_key is None:
|
||||||
session_key = message.content['COOKIES'].get(settings.SESSION_COOKIE_NAME)
|
session_key = message.content['cookies'].get(settings.SESSION_COOKIE_NAME)
|
||||||
# Make a session storage
|
# Make a session storage
|
||||||
if session_key:
|
if session_key:
|
||||||
session_engine = import_module(settings.SESSION_ENGINE)
|
session_engine = import_module(settings.SESSION_ENGINE)
|
||||||
|
|
|
@ -10,10 +10,10 @@ def encode_request(request):
|
||||||
"""
|
"""
|
||||||
# TODO: More stuff
|
# TODO: More stuff
|
||||||
value = {
|
value = {
|
||||||
"GET": dict(request.GET.lists()),
|
"get": dict(request.GET.lists()),
|
||||||
"POST": dict(request.POST.lists()),
|
"post": dict(request.POST.lists()),
|
||||||
"COOKIES": request.COOKIES,
|
"cookies": request.COOKIES,
|
||||||
"META": {k: v for k, v in request.META.items() if not k.startswith("wsgi")},
|
"meta": {k: v for k, v in request.META.items() if not k.startswith("wsgi")},
|
||||||
"path": request.path,
|
"path": request.path,
|
||||||
"path_info": request.path_info,
|
"path_info": request.path_info,
|
||||||
"method": request.method,
|
"method": request.method,
|
||||||
|
@ -27,10 +27,10 @@ def decode_request(value):
|
||||||
Decodes a request JSONish value to a HttpRequest object.
|
Decodes a request JSONish value to a HttpRequest object.
|
||||||
"""
|
"""
|
||||||
request = HttpRequest()
|
request = HttpRequest()
|
||||||
request.GET = CustomQueryDict(value['GET'])
|
request.GET = CustomQueryDict(value['get'])
|
||||||
request.POST = CustomQueryDict(value['POST'])
|
request.POST = CustomQueryDict(value['post'])
|
||||||
request.COOKIES = value['COOKIES']
|
request.COOKIES = value['cookies']
|
||||||
request.META = value['META']
|
request.META = value['meta']
|
||||||
request.path = value['path']
|
request.path = value['path']
|
||||||
request.method = value['method']
|
request.method = value['method']
|
||||||
request.path_info = value['path_info']
|
request.path_info = value['path_info']
|
||||||
|
|
|
@ -34,10 +34,10 @@ Standard channel name is ``http.request``.
|
||||||
|
|
||||||
Contains the following keys:
|
Contains the following keys:
|
||||||
|
|
||||||
* GET: List of (key, value) tuples of GET variables (keys 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)
|
* 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)
|
* 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)
|
* 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: 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``.
|
* path_info: String, like ``path`` but without any script prefix. Often just ``path``.
|
||||||
* method: String, upper-cased HTTP method
|
* method: String, upper-cased HTTP method
|
||||||
|
|
Loading…
Reference in New Issue
Block a user