question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: "http.response.sendfile" extension.

See original GitHub issue

Add 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:closed
  • Created 3 years ago
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
abersheerancommented, Oct 5, 2021
0reactions
abersheerancommented, Oct 5, 2021

loop.sendfile just wraps os.sendfile.

The standard uses integer (file descriptor) to make it easier for servers written in C, Rust, and so on to handle this.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found