Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FilesHandler not meet RFC 6713 #6287

Closed
wants to merge 9 commits into from
7 changes: 6 additions & 1 deletion notebook/files/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,14 @@ 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)
else:
Expand Down