Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

session not saved with web.FileResponse #640

Open
Benj1 opened this issue Nov 15, 2021 · 3 comments
Open

session not saved with web.FileResponse #640

Benj1 opened this issue Nov 15, 2021 · 3 comments

Comments

@Benj1
Copy link

Benj1 commented Nov 15, 2021

I'm not sure if there's a reason to exclude it, but it seems that sessions aren't saved when response is an instance of web.FileResponse.
It gets excluded here when checking the type of the response:

if not isinstance(response, (web.Response, web.HTTPException)):
# likely got websocket or streaming
return response

@Dreamsorcerer
Copy link
Member

Have you tried removing the check and seeing if it works as expected?

@Benj1
Copy link
Author

Benj1 commented Nov 19, 2021

Yes, changing to isinstance(response, (web.Response, web.HTTPException, web.FileResponse)) allows sessions to be set when returning static file responses

@asvetlov
Copy link
Member

When I designed aiohttp-session, I made it work with non-streaming responses only.
Theoretically, the library can register on_response_prepare signal to dynamically update the response cookie if needed.
It can allow the processing of all responses, doesn't matter they are streamed or not.
Sorry, I have no idea when I can find time to work on the issue, any contribution is welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants