Skip to content

Commit

Permalink
Fix FilesHandler not meet RFC 6713 (#701)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wh1isper authored Feb 18, 2022
1 parent 745f5ba commit 62607ce
Showing 1 changed file with 6 additions and 2 deletions.
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

0 comments on commit 62607ce

Please sign in to comment.