Unused response_factory argument of web.UrlDispatcher.add_static/web.StaticResource #2290
Closed
Description
Long story short
Argument response_factory doesn't affect static responses
Expected behaviour
aiohttp should call custom class passed to aiohttp.web.UrlDispatcher.add_static()
Actual behaviour
response_factory value is ignored
Steps to reproduce
class CORSStreamResponse(web.StreamResponse):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if 'Access-Control-Allow-Origin' not in self.headers:
self.headers['Access-Control-Allow-Origin'] = '*'
# ...
app.router.add_static('/static', f'./static', name='static', response_factory=CORSStreamResponse)$ curl -I http://localhost:8000/static/bundle.js
HTTP/1.1 200 OK
Content-Type: application/javascript
Last-Modified: Tue, 19 Sep 2017 10:08:45 GMT
Content-Length: 84833
Date: Mon, 25 Sep 2017 14:07:59 GMT
Server: Python/3.6 aiohttp/2.2.5
Your environment
aiohttp==2.2.5