Skip to content

Commit aaa9a0d

Browse files
author
jizhongsheng
committed
Fix FilesHandler not meet RFC 6713
1 parent 2662634 commit aaa9a0d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

notebook/files/handlers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,16 @@ def get(self, path, include_body=True):
5959
if name.lower().endswith('.ipynb'):
6060
self.set_header('Content-Type', 'application/x-ipynb+json')
6161
else:
62-
cur_mime = mimetypes.guess_type(name)[0]
62+
cur_mime, encoding = mimetypes.guess_type(name)
6363
if cur_mime == 'text/plain':
6464
self.set_header('Content-Type', 'text/plain; charset=UTF-8')
65+
# RFC 6713
66+
if encoding == 'gzip':
67+
self.set_header('Content-Type', 'application/gzip')
68+
elif encoding is not None:
69+
self.set_header('Content-Type', 'application/octet-stream')
6570
elif cur_mime is not None:
66-
self.set_header('Content-Type', cur_mime)
71+
self.set_header("Content-Type", cur_mime)
6772
else:
6873
if model['format'] == 'base64':
6974
self.set_header('Content-Type', 'application/octet-stream')

0 commit comments

Comments
 (0)