From d8ed35a546ea69db7196098f0852cf267e728b64 Mon Sep 17 00:00:00 2001 From: pcdinh Date: Tue, 25 Oct 2016 18:49:41 +0700 Subject: [PATCH] Fixed: uninitialized headers --- sanic/response.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sanic/response.py b/sanic/response.py index 88925035..2f7ae90f 100644 --- a/sanic/response.py +++ b/sanic/response.py @@ -168,6 +168,7 @@ async def file(location, mime_type=None, headers=None, force_download=False): out_stream = await _file.read() # Do not attempt to render file in browser if force_download is True: + headers = headers if headers is not None else {} headers["Content-Disposition"] = "attachment; filename=%s" % filename mime_type = 'application/octet-stream' else: