Skip to content

Commit

Permalink
Fix FilesHandler not meet RFC 6713
Browse files Browse the repository at this point in the history
  • Loading branch information
jizhongsheng committed Feb 18, 2022
1 parent 2662634 commit aaa9a0d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions notebook/files/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,16 @@ def get(self, path, include_body=True):
if name.lower().endswith('.ipynb'):
self.set_header('Content-Type', 'application/x-ipynb+json')
else:
cur_mime = mimetypes.guess_type(name)[0]
cur_mime, encoding = mimetypes.guess_type(name)
if cur_mime == 'text/plain':
self.set_header('Content-Type', 'text/plain; charset=UTF-8')
# RFC 6713
if encoding == 'gzip':
self.set_header('Content-Type', 'application/gzip')
elif encoding is not None:
self.set_header('Content-Type', 'application/octet-stream')
elif cur_mime is not None:
self.set_header('Content-Type', cur_mime)
self.set_header("Content-Type", cur_mime)
else:
if model['format'] == 'base64':
self.set_header('Content-Type', 'application/octet-stream')
Expand Down

0 comments on commit aaa9a0d

Please sign in to comment.