Skip to content

Commit 62607ce

Browse files
author
Wh1isper
authored
Fix FilesHandler not meet RFC 6713 (#701)
1 parent 745f5ba commit 62607ce

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

jupyter_server/files/handlers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from jupyter_server.base.handlers import JupyterHandler
1212
from jupyter_server.utils import ensure_async
1313

14-
1514
AUTH_RESOURCE = "contents"
1615

1716

@@ -65,9 +64,14 @@ async def get(self, path, include_body=True):
6564
if name.lower().endswith(".ipynb"):
6665
self.set_header("Content-Type", "application/x-ipynb+json")
6766
else:
68-
cur_mime = mimetypes.guess_type(name)[0]
67+
cur_mime, encoding = mimetypes.guess_type(name)
6968
if cur_mime == "text/plain":
7069
self.set_header("Content-Type", "text/plain; charset=UTF-8")
70+
# RFC 6713
71+
if encoding == "gzip":
72+
self.set_header("Content-Type", "application/gzip")
73+
elif encoding is not None:
74+
self.set_header("Content-Type", "application/octet-stream")
7175
elif cur_mime is not None:
7276
self.set_header("Content-Type", cur_mime)
7377
else:

0 commit comments

Comments
 (0)