gpt4 book ai didi

python - 允许逐跳 header Django

转载 作者:太空宇宙 更新时间:2023-11-03 13:43:12 25 4
gpt4 key购买 nike

我正在使用 Django 1.6 和 Python 3.4 编写一个演示代理服务器。当响应具有此 header 时我收到错误消息:

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 运行服务器。

请帮忙

最佳答案

以下 HTTP/1.1 header 是 wsgiref 不允许的逐跳 header :

  - Connection
- Keep-Alive
- Proxy-Authenticate
- Proxy-Authorization
- TE
- Trailers
- Transfer-Encoding
- Upgrade

参见:

  1. Hypertext Transfer Protocol -- HTTP/1.1
  2. wsgiref 的代码:util.py , handlers.py

关于python - 允许逐跳 header Django,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26044167/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com