-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Use StaticFileHandler when files are local #2656
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
Conversation
takluyver
left a comment
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.
|
|
||
| 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_classis added as an attribute toContentsManager, specifying a custom request handler for the/filesrequests. ForFileContentsManager, this is set toAuthenticatedFilesHandler(which is a light proxy over Tornado'sStaticFileHandler).Using tornado's
StaticFileHandlerclass 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_managertest case to allow bothtext/plainand
text/plain; charset=UTF-8as acceptablecontent-types. The reason being that whileFilesHandlerexplicitly 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.