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 #701

Merged
merged 1 commit into from
Feb 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions jupyter_server/files/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from jupyter_server.base.handlers import JupyterHandler
from jupyter_server.utils import ensure_async


AUTH_RESOURCE = "contents"


Expand Down Expand Up @@ -65,9 +64,14 @@ async 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