Django发送分块响应

Era*_*lpB 5 django wsgi nginx django-wsgi gunicorn

我的设置是 Django->Gunicorn->Nginx

虽然我不使用HttpStreamingResponse,但浏览器看到Transfer-encoding: chunked这会导致 Cloudfront 出现问题(它不会自动压缩分块响应)

我的 gunicorn 使用默认值运行,所以默认工作人员等,我在 nginx 中找不到任何关于此的选项。

我应该停止使用分块吗?如果是这样怎么办?

我发现这个https://github.com/abrookins/streaming_django提到

First, some conditions must be true:

- The client must be speaking HTTP/1.1 or newer
- The request method wasn't a HEAD
- The response does not include a Content-Length header
- The response status wasn't 204 or 304

If these conditions are true, then Gunicorn will add a Transfer-Encoding: chunked header to the response, signaling to the client that the response will stream in chunks.

In fact, Gunicorn will respond with Transfer-Encoding: chunked even if you used an HttpResponse, if those conditions are true!
Run Code Online (Sandbox Code Playgroud)

但这是否意味着我应该去每个视图并添加我的内容长度?我的 Django 没有做到这一点吗?