Proposal: "http.response.sendfile" extension.
See original GitHub issueAdd the sendfile extension to allow ASGI programs to return response through sendfile
.
In scope
:
"scope": {
...
"extensions": {
"http.response.sendfile": {},
},
}
Response:
await send({"type": "http.response.start", ...})
await send({"type": "http.response.sendfile", "file": file-obj})
Some related links:
https://docs.python.org/3.7/library/asyncio-eventloop.html#asyncio.loop.sendfile https://github.com/encode/uvicorn/issues/35
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (10 by maintainers)
Top Results From Across the Web
Node.js send file in response - Stack Overflow
Here's an example program that will send myfile.mp3 by streaming it from disk (that is, it doesn't read the whole file into memory...
Read more >Content-Disposition - HTTP - MDN Web Docs
In a regular HTTP response, the Content-Disposition response header is a header indicating if the content is expected to be displayed inline ...
Read more >Express.js res.sendFile() Function - GeeksforGeeks
The res.sendFile() function basically transfers the file at the given path and it sets the Content-Type response HTTP header field based on ...
Read more >Request & Response Objects - 4.x - CakePHP Cookbook
The request object in CakePHP allows you to introspect an incoming request, while the response object allows you to effortlessly create HTTP responses...
Read more >#2131 (HttpResponseSendFile for serving static files handler ...
It uses response.sendfile() on mod_python, FileWrapper on wsgi. ... HttpResponse is implemented as an iterator so it fits perfectly to read the file...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@synodriver Maybe the PR https://github.com/encode/uvicorn/pull/1210 can help you.
loop.sendfile
just wrapsos.sendfile
.The standard uses integer (file descriptor) to make it easier for servers written in C, Rust, and so on to handle this.