python - 连接中断 : IncompleteRead(0 bytes read) when sending request to Django on Heroku

标签 python django python-3.x heroku python-requests

我有一个在 Django 中返回 JsonResponse 的 View

def some_view(request):
    return JsonResponse({'a': 1, 'b': 2})

在同一个项目的其他地方,我有一段代码向对应于该 View 的 url 发送 GET 请求:
import requests
def client_func():
    requests.get(url_to_some_views)

它在我的本地机器上工作,但在部署到 heroku 后,有时我会收到错误:('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))
经过一番测试,我发现some_view的响应头中多了一个字段。 :transfer-encoding: chunked所以我想这可能是导致问题的原因,但我仍然不确定如何处理。到目前为止,我已经尝试添加 stream=Trueclient_func 中的 get 电话但问题仍然存在。

有人可以帮助我解决这可能是我问题的原因并解决这个问题。非常感谢!

最佳答案

发现了问题,这是因为我的 1 个 GET 请求有一个主体,并且把事情搞砸了。

关于python - 连接中断 : IncompleteRead(0 bytes read) when sending request to Django on Heroku,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51189327/

相关文章:

python - 如何将参数列表转换为 Python 中的单个字符串命令行?

python - django 是否有一个静态查找器可以在鸡蛋中查找静态?

python - Heroku 部署 - PermissionError : [Errno 13] Permission denied: '/etc/passwd-'

python - Errno 65 尝试发送电子邮件时没有到主机的路由

python - 嵌套单行循环

python - 模拟帝国时代 3 中的按键

python-3.x - semaphore_tracker : There appear to be 1 leaked semaphores to clean up at shutdown len(cache))

python - 如何从 Pyramid 内提供 wsgi 应用程序?

python - Django:刚开始学django 应该用django 还是jinja2 模板

python - 如何在python中为类添加属性