Changes between Initial Version and Version 1 of Ticket #31949, comment 3
- Timestamp:
- Aug 27, 2020, 12:34:13 AM (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #31949, comment 3
initial v1 3 3 > 4 4 > An issue with the MiddlewareMixin subclasses is already handled in #31928. 5 I had n't opened the ticket, so that's already addressed.5 I had not checked the ticket, so that's already addressed. 6 6 > 7 7 > You should be able to chain them with `@sync_to_async()`, if necessary. Am I missing sth? … … 32 32 {{{ 33 33 def xframe_options_deny(view_func): 34 def wrapped_view(*args, **kwargs): 35 resp = view_func(*args, **kwargs) 34 def process_response(resp): 36 35 if resp.get('X-Frame-Options') is None: 37 36 resp['X-Frame-Options'] = 'DENY' 38 37 return resp 39 38 39 def wrapped_view(*args, **kwargs): 40 resp = view_func(*args, **kwargs) 41 return process_response(resp) 42 40 43 async def wrapped_view_async(*args, **kwargs): 41 44 resp = await view_func(*args, **kwargs) 42 if resp.get('X-Frame-Options') is None: 43 resp['X-Frame-Options'] = 'DENY' 44 return resp 45 return process_response(resp) 45 46 46 47 return wraps(view_func)(wrapped_view_async if asyncio.iscoroutinefunction(view_func) else wrapped_view)