diff --git a/django/core/servers/basehttp.py b/django/core/servers/basehttp.py
index 19b287a..e95b96c 100644
a
|
b
|
class WSGIRequestHandler(simple_server.WSGIRequestHandler, object):
|
144 | 144 | env['SERVER_PROTOCOL'] = self.request_version |
145 | 145 | env['REQUEST_METHOD'] = self.command |
146 | 146 | if '?' in self.path: |
147 | | path,query = self.path.split('?',1) |
| 147 | path,query = self.path.split(str('?'),1) |
148 | 148 | else: |
149 | 149 | path,query = self.path,'' |
150 | 150 | |
151 | 151 | env['PATH_INFO'] = unquote(path) |
152 | 152 | env['QUERY_STRING'] = query |
153 | 153 | env['REMOTE_ADDR'] = self.client_address[0] |
154 | | env['CONTENT_TYPE'] = self.headers.get('content-type', 'text/plain') |
| 154 | env['CONTENT_TYPE'] = self.headers.get('content-type', str('text/plain')) |
155 | 155 | |
156 | 156 | length = self.headers.get('content-length') |
157 | 157 | if length: |
diff --git a/tests/regressiontests/servers/tests.py b/tests/regressiontests/servers/tests.py
index c90c785..f54e34c 100644
a
|
b
|
|
| 1 | # -*- encoding: utf-8 -*- |
1 | 2 | """ |
2 | 3 | Tests for django.core.servers. |
3 | 4 | """ |
| 5 | from __future__ import unicode_literals |
| 6 | |
4 | 7 | import os |
5 | 8 | try: |
6 | 9 | from urllib.request import urlopen, HTTPError |
… |
… |
from django.core.exceptions import ImproperlyConfigured
|
11 | 14 | from django.test import LiveServerTestCase |
12 | 15 | from django.core.servers.basehttp import WSGIServerException |
13 | 16 | from django.test.utils import override_settings |
| 17 | from django.utils.http import urlencode |
14 | 18 | |
15 | 19 | from .models import Person |
16 | 20 | |
… |
… |
class LiveServerViews(LiveServerBase):
|
134 | 138 | f = self.urlopen('/media/example_media_file.txt') |
135 | 139 | self.assertEqual(f.read().rstrip(b'\r\n'), b'example media file') |
136 | 140 | |
| 141 | def test_environ(self): |
| 142 | f = self.urlopen('/environ_view/?%s' % urlencode({'q': 'тест'})) |
| 143 | self.assertIn(b"QUERY_STRING: 'q=%D1%82%D0%B5%D1%81%D1%82'", f.read()) |
| 144 | |
137 | 145 | |
138 | 146 | class LiveServerDatabase(LiveServerBase): |
139 | 147 | |
diff --git a/tests/regressiontests/servers/urls.py b/tests/regressiontests/servers/urls.py
index c8ca1ac..a857c45 100644
a
|
b
|
urlpatterns = patterns('',
|
9 | 9 | url(r'^example_view/$', views.example_view), |
10 | 10 | url(r'^model_view/$', views.model_view), |
11 | 11 | url(r'^create_model_instance/$', views.create_model_instance), |
12 | | ) |
13 | | No newline at end of file |
| 12 | url(r'^environ_view/$', views.environ_view), |
| 13 | ) |
diff --git a/tests/regressiontests/servers/views.py b/tests/regressiontests/servers/views.py
index 94a4f2d..00baf4b 100644
a
|
b
|
def model_view(request):
|
14 | 14 | def create_model_instance(request): |
15 | 15 | person = Person(name='emily') |
16 | 16 | person.save() |
17 | | return HttpResponse('') |
18 | | No newline at end of file |
| 17 | return HttpResponse('') |
| 18 | |
| 19 | |
| 20 | def environ_view(request): |
| 21 | return HttpResponse("\n".join(["%s: %r" % (k, v) for k, v in request.environ.items()])) |