StreamingHttpResponse being buffered when using uvicorn/gunicorn/daphne in Django
I have a very simple view that Streams a repsonse. When using python manage.py runserver
the stream works as expected. But, when we use uvicorn app.asgi:application or daphne app.asgi:application or gunicorn app.asgi:application the stream is buffered in the UI and the response arrives completed instead of by chunks.
result = core_services.generate_ai_v3_response(
prompt=prompt,
previous_response_id=previous_response_id,
broker_id=broker_id,
)
response = StreamingHttpResponse(result, content_type="text/event-stream")
# Add proper streaming headers
# Add aggressive streaming headers
response["Cache-Control"] = "no-cache"
response["X-Accel-Buffering"] = "no"
return response