Comments (4)
If you'd like to make a PR to revert that section and include a test that exhibits the problem, we can probably include it.
I'm still not entirely clear why this fails though, I'm curious what the subclass does that breaks when converting to a Path.
from aiohttp.
If you'd like to make a PR to revert that section and include a test that exhibits the problem, we can probably include it.
I created a draft PR. It needs some more thought and work. It just reverts the change, but that is not right solution because it also reverts support for all os.PathLike
. It would need to create a pathlib.Path
for those that are os.PathLike
, but not already compatible with pathlib.Path
.
I'll probably add @runtime_checkable
to the PathlibPathLike
or some hasattr
calls to see if the passed object has required pathlib.Path
attributes before using it as is.
I'm still not entirely clear why this fails though, I'm curious what the subclass does that breaks when converting to a Path.
The subclass of pathlib.Path
replaces stat
and open
such that it can make the response without the file being on filesystem. The file is created in-memory and having to write it to filesystem just to make a response is pointless. pathlib.Path
fails since it can not find it on the filesystem.
from aiohttp.
I use web.FileResponse to respond with a file that is not really on the disk. This is done with a Path instance that implements the pathlib.Path interface.
What's the actual data? Are you opening a file and just want to keep it open? It would not be terribly difficult to allow the constructor to also accept a file object, in particular an instance of BufferedIOBase
. The user would just also have to provide the content type since that is guessed from the file extension.
from aiohttp.
What's the actual data? Are you opening a file and just want to keep it open? It would not be terribly difficult to allow the constructor to also accept a file object, in particular an instance of
BufferedIOBase
. The user would just also have to provide the content type since that is guessed from the file extension.
It is not a file at all. It is in-memory generated media data that changes infrequently and has timestamp and content-type from the extension. I like to use the implementation of RFC 7232 and RFC 7233 that is in FileResponse.
from aiohttp.
Related Issues (20)
- Expiring the cookie jar is unexpectedly expensive HOT 8
- WSS receive_json/string/binary API error handling HOT 5
- Using eager task factory with aiohttp 3.10.0 and cpython 3.12+ raise an AssertionError in stdlib `asyncio.staggered` HOT 11
- Error while trying to use unix socket, when `aiohttp`>=3.10 HOT 11
- The `timeout` parameter of `aiohttp.ClientSession` does work for types other than `Union[ClientTimeout, _SENTINEL, None]` HOT 5
- Analyze additional places where there is timer handle churn HOT 7
- Risk of websocket ping tasks being garbage collected before they finish HOT 1
- Remove wait_for_disconnection
- Remove `allowed_protocol_schema_set` backwards compat in `BaseConnector` HOT 1
- Multipart reader fails on Transfer-Encoding: chunked HOT 9
- pytest example in testing.rst throws TypeError: 'async_generator' object is not callable HOT 2
- Response object reference to session returns None HOT 2
- ClientResponse.json() doesn't set status code HOT 3
- [typing] mypy errors when trying to extract headers when type is `LooseHeaders` HOT 1
- Support free-threaded Python 3.13 build HOT 2
- Visual bug in the docs HOT 5
- TypeError: _patch_task.<locals>.task_new_init() got an unexpected keyword argument 'eager_start' HOT 5
- Sending default 'Server' header when failing on wrong HTTP method HOT 6
- Websocket ping test has transient failures on loaded systems HOT 1
- Send 100-continue only when handler reads body
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aiohttp.