我的设置是Django-> Gunicorn-> Nginx
虽然我不使用HttpStreamingResponse
,但浏览器会看到Transfer-encoding: chunked
这会导致Cloudfront出现问题(它不会自动压缩分块响应)
我的gunicorn使用默认值运行,因此默认工作等等。我在nginx中找不到任何关于此的选项。
我应该停止使用chunked吗?如果是这样的话?
我发现这个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!
但这是否意味着我应该转到每个视图并添加我的内容长度?我的Django没有这样做吗?