-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Make StaticRoute support Last-Modified and If-Modified-Since headers #386
Conversation
self.assertIsNotNone(lastmod) | ||
resp.close() | ||
|
||
resp = yield from request('GET', url, loop=self.loop, |
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.
Please split the test into several (five?) ones.
The PR is good but I guess to add |
See also #165 |
I've split the tests somewhat (some of them are superfluous though). Would you like the |
Yes, properties make sense only if they have By standard it is timestamp. If you need arbitrary data like hash please use ETAG header. |
Something like this then? I think it's overengineering, to be honest. |
@@ -65,6 +69,33 @@ def content_length(self, _CONTENT_LENGTH=hdrs.CONTENT_LENGTH): | |||
else: | |||
return int(l) | |||
|
|||
@property | |||
def if_modified_since(self, _IF_MODIFIED_SINCE=hdrs.IF_MODIFIED_SINCE): |
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.
Move it into Request object: it's request-only header
I want to make properties for all common HTTP headers eventually. |
Make StaticRoute support Last-Modified and If-Modified-Since headers
Thanks! |
This change makes
StaticRoute
addLast-Modified
headers to the responses and recognizeIf-Modified-Since
headers in the requests. IfIf-Modified-Since
header is present and is equal to the modification time of the file being served,StaticRoute
will now respond with a 304 "Not Modified" response.This is a small feature, but rather useful if you hit "Refresh" button often.