【发布时间】:2014-11-20 13:21:00
【问题描述】:
我正在用 Django 1.6 和 Python 3.4 编写一个演示代理服务器。当响应包含此标头时出现错误:
Transfer-Encoding=chunked
错误是:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/contrib/staticfiles/handlers.py", line 67, in __call__
return self.application(environ, start_response)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/handlers/wsgi.py", line 214, in __call__
start_response(force_str(status), response_headers)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/wsgiref/handlers.py", line 236, in start_response
assert not is_hop_by_hop(name),"Hop-by-hop headers not allowed"
AssertionError: Hop-by-hop headers not allowed
我发现了这个问题:Allow hop-by-hop headers in Django proxy middleware 但似乎 Django 1.6 没有 basehttp._hop_headers。
我使用python3.4 manage.py runserver 运行服务器。
请帮忙
【问题讨论】:
-
“一个带有 django 的演示代理服务器”?为什么要在 django 中编写代理服务器?最好使用 Python 之类的 werkzeug。
-
这里有 Django 1.6 和 Python 2.7 的类似问题。我怀疑这就是 manage.py 的工作方式。我团队的另一位成员能够设置在 uWSGI 下运行的传输编码标头,并且运行没有错误。
-
_hop_headers现在在wsgiref.util。
标签: python django wsgi chunked