Skip to content

Commit

Permalink
Lowercase request GET/POST etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgodwin committed Sep 10, 2015
1 parent 70caf7d commit 2dd7f58
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions channels/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions channels/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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']
Expand Down
8 changes: 4 additions & 4 deletions docs/message-standards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2dd7f58

Please sign in to comment.