mirror of
https://github.com/django/daphne.git
synced 2025-07-11 00:12:18 +03:00
commit
dfc11d4a67
|
@ -8,8 +8,8 @@ def encode_request(request):
|
||||||
"""
|
"""
|
||||||
# TODO: More stuff
|
# TODO: More stuff
|
||||||
value = {
|
value = {
|
||||||
"GET": request.GET.items(),
|
"GET": list(request.GET.items()),
|
||||||
"POST": request.POST.items(),
|
"POST": list(request.POST.items()),
|
||||||
"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,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
from six import PY3
|
||||||
|
|
||||||
|
|
||||||
def encode_response(response):
|
def encode_response(response):
|
||||||
|
@ -10,8 +11,10 @@ def encode_response(response):
|
||||||
"content_type": getattr(response, "content_type", None),
|
"content_type": getattr(response, "content_type", None),
|
||||||
"content": response.content,
|
"content": response.content,
|
||||||
"status_code": response.status_code,
|
"status_code": response.status_code,
|
||||||
"headers": response._headers.values(),
|
"headers": list(response._headers.values()),
|
||||||
}
|
}
|
||||||
|
if PY3:
|
||||||
|
value["content"] = value["content"].decode('utf8')
|
||||||
response.close()
|
response.close()
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import types
|
import types
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
|
|
||||||
|
from six import PY3
|
||||||
|
|
||||||
def auto_import_consumers():
|
def auto_import_consumers():
|
||||||
"""
|
"""
|
||||||
|
@ -12,8 +13,13 @@ def auto_import_consumers():
|
||||||
try:
|
try:
|
||||||
__import__(module_name)
|
__import__(module_name)
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
if "no module named %s" % submodule not in str(e).lower():
|
err = str(e).lower()
|
||||||
raise
|
if PY3:
|
||||||
|
if "no module named '%s'" % (module_name,) not in err:
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
if "no module named %s" % (submodule,) not in err:
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
def name_that_thing(thing):
|
def name_that_thing(thing):
|
||||||
|
|
|
@ -175,7 +175,9 @@ to test your new code::
|
||||||
socket.onmessage = function(e) {
|
socket.onmessage = function(e) {
|
||||||
alert(e.data);
|
alert(e.data);
|
||||||
}
|
}
|
||||||
socket.send("hello world");
|
socket.onopen = function() {
|
||||||
|
socket.send("hello world");
|
||||||
|
}
|
||||||
|
|
||||||
You should see an alert come back immediately saying "hello world" - your
|
You should see an alert come back immediately saying "hello world" - your
|
||||||
message has round-tripped through the server and come back to trigger the alert.
|
message has round-tripped through the server and come back to trigger the alert.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user