What normally should be the content_type for a
I’m outputting chunks of JSON data and I fetching it on the client side as chunks of data -
const reader = response.body.getReader();
response = StreamingHttpResponse(foo(arg1, arg2), content_type="application/json")
The content_type depends on the content you are going to share to your client.
In your case
application/json is correct as you are sharing JSON data as you stated.
If you have to share some binary data like image then the content_type would be like
But the data is being sent in chunks over a period of time as a single json object.
I read that in such cases we set the content-type as application/octet-stream ?
The MIME type identifies how the data is to be interpreted, not how it is going to be delivered.
If you are processing the data stream as binary data, one chunk at a time, then the
octet-stream type may be appropriate. But if the entire response is a single “entity” (one file or data structure), then it’s more appropriate to identify the MIME type accordingly.