Skip to content

Commit

Permalink
Postfix #2319: Don't set content type twice
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Oct 13, 2017
1 parent 12af78b commit 4ffdb3a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions aiohttp/web_fileresponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,10 @@ def prepare(self, request):
ct, encoding = mimetypes.guess_type(str(filepath))
if not ct:
ct = 'application/octet-stream'
should_set_ct = True
else:
ct = self.headers[hdrs.CONTENT_TYPE]
encoding = 'gzip' if gzip else None
should_set_ct = False

status = HTTPOk.status_code
file_size = st.st_size
Expand Down Expand Up @@ -228,7 +229,8 @@ def prepare(self, request):
status = HTTPPartialContent.status_code

self.set_status(status)
self.content_type = ct
if should_set_ct:
self.content_type = ct
if encoding:
self.headers[hdrs.CONTENT_ENCODING] = encoding
if gzip:
Expand Down

0 comments on commit 4ffdb3a

Please sign in to comment.