Closed
Description
Long story short
I am using FileResponse to return a file. However, if I pass a status to __init__() it is overwritten with 200 in FileResponse.prepare(). This looks like a bug as it should probably only overwrite this value when handling a range request.
Relevant lines:
https://github.com/aio-libs/aiohttp/blob/master/aiohttp/web_fileresponse.py#L248
https://github.com/aio-libs/aiohttp/blob/master/aiohttp/web_fileresponse.py#L322
I will open a PR shortly.
Expected behaviour
I expect the HTTP status code I desire to be emitted to the client.
Actual behaviour
HTTP status is always 200.
Steps to reproduce
import os
import tempfile
import aiohttp
def handler(request):
fd, path = tempfile.mkstemp()
os.close(fd)
response = web.FileResponse(path, status=203)
return response
if __name__ == '__main__':
app = web.Application()
app.add_routes([web.get('/', handler)])
web.run_app(app, port=3000)Your environment
Ubuntu 18.04, I am using aiohttp==3.6.1, but master has the same issue.
Metadata
Assignees
Labels
No labels