Closed gi0baro closed 10 months ago
As suggested by @Kludex
ASGI protocol might take advantage of granian capability of directly serve files from a path, like already implemented in RSGI proto.response_file.
proto.response_file
This would require to open up a PR to https://github.com/django/asgiref adding the new extra, which might look like the following:
"scope": { ... "extensions": { "http.response.file_path": {}, }, }
With the above extra definition, a new event might be produced by ASGI applications, with the following keys:
type
file_path
The ASGI application is still responsible to send the http.response.start event with the relevant headers (eg: content-type, content-length, etc.)
http.response.start
content-type
content-length
As suggested by @Kludex
ASGI protocol might take advantage of granian capability of directly serve files from a path, like already implemented in RSGI
proto.response_file
.This would require to open up a PR to https://github.com/django/asgiref adding the new extra, which might look like the following:
With the above extra definition, a new event might be produced by ASGI applications, with the following keys:
type
(Unicode string): "http.response.file_path"file_path
(Unicode string): The string representation of the file path to serve (platform specific)The ASGI application is still responsible to send the
http.response.start
event with the relevant headers (eg:content-type
,content-length
, etc.)