mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-12 11:45:38 +08:00
Merge pull request #2402 from gnestor/utf-8
Specify `charset=UTF-8` when serving non-base64 files
This commit is contained in:
commit
469b1c84be
@ -46,13 +46,15 @@ class FilesHandler(IPythonHandler):
|
||||
self.set_header('Content-Type', 'application/x-ipynb+json')
|
||||
else:
|
||||
cur_mime = mimetypes.guess_type(name)[0]
|
||||
if cur_mime is not None:
|
||||
if cur_mime == 'text/plain':
|
||||
self.set_header('Content-Type', 'text/plain; charset=UTF-8')
|
||||
elif cur_mime is not None:
|
||||
self.set_header('Content-Type', cur_mime)
|
||||
else:
|
||||
if model['format'] == 'base64':
|
||||
self.set_header('Content-Type', 'application/octet-stream')
|
||||
else:
|
||||
self.set_header('Content-Type', 'text/plain')
|
||||
self.set_header('Content-Type', 'text/plain; charset=UTF-8')
|
||||
|
||||
if include_body:
|
||||
if model['format'] == 'base64':
|
||||
|
@ -95,7 +95,7 @@ class FilesTest(NotebookTestBase):
|
||||
|
||||
r = self.request('GET', 'files/test.txt')
|
||||
self.assertEqual(r.status_code, 200)
|
||||
self.assertEqual(r.headers['content-type'], 'text/plain')
|
||||
self.assertEqual(r.headers['content-type'], 'text/plain; charset=UTF-8')
|
||||
self.assertEqual(r.text, 'foobar')
|
||||
|
||||
def test_download(self):
|
||||
|
Loading…
Reference in New Issue
Block a user