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

Allow Response Streaming from Generators #2

Merged
merged 2 commits into from
Aug 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ckanext/csrf_filter/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

from logging import getLogger
from types import GeneratorType

from ckan import plugins
from ckan.plugins import implements, toolkit
Expand Down Expand Up @@ -95,6 +96,10 @@ def check_csrf():
def set_csrf_token(response):
""" Apply a CSRF token to all response bodies.
"""
if hasattr(response, 'response') \
and isinstance(response.response, GeneratorType):
return response

response.direct_passthrough = False
anti_csrf.apply_token(response)
return response
Expand Down
Loading