-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Use StaticFileHandler when files are local #2656
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notebook/tests/test_files.py
Outdated
@@ -95,7 +95,7 @@ def test_contents_manager(self): | |||
|
|||
r = self.request('GET', 'files/test.txt') | |||
self.assertEqual(r.status_code, 200) | |||
self.assertEqual(r.headers['content-type'], 'text/plain; charset=UTF-8') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the tests are passing on Travis... It looks good to me. What says @minrk?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can define AuthenticatedFileHandler.get_content_type to include the charset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you requesting that @agermanidis does that in this PR, or suggesting that we do it separately?
Thanks, I wasn't aware of |
Thanks @agermanidis!! We appreciate your contribution! |
Implements the set of changes described at #968, and fixes #1024.
In summary, a
files_handler_class
is added as an attribute toContentsManager
, specifying a custom request handler for the/files
requests. ForFileContentsManager
, this is set toAuthenticatedFilesHandler
(which is a light proxy over Tornado'sStaticFileHandler
).Using tornado's
StaticFileHandler
class for serving local files is more efficient and enables HTTP Range requests, which are necessary for seekable video embeds (see #1024).An additional change is made to the
test_contents_manager
test case to allow bothtext/plain
and
text/plain; charset=UTF-8
as acceptablecontent-type
s. The reason being that whileFilesHandler
explicitly specifies the content type (here), Tornado's static file handler just sets the content type to the mime-type of the file, which doesn't include charset; overwriting that would be awkward.This is my first time digging through this codebase so any changes/comments/suggestions would be much appreciated.