mirror of
https://github.com/django/django.git
synced 2024-12-01 15:42:04 +01:00
Fixed #18675 -- Fixed was_modified_since with floating-point mtime
Thanks Simon Charette for the patch.
This commit is contained in:
parent
b3ee80a0cf
commit
3cbe686af6
@ -138,7 +138,7 @@ def was_modified_since(header=None, mtime=0, size=0):
|
||||
header_len = matches.group(3)
|
||||
if header_len and int(header_len) != size:
|
||||
raise ValueError
|
||||
if mtime > header_mtime:
|
||||
if int(mtime) > header_mtime:
|
||||
raise ValueError
|
||||
except (AttributeError, ValueError, OverflowError):
|
||||
return True
|
||||
|
@ -7,4 +7,4 @@ from .defaults import DefaultsTests
|
||||
from .i18n import JsI18NTests, I18NTests, JsI18NTestsMultiPackage
|
||||
from .shortcuts import ShortcutTests
|
||||
from .specials import URLHandling
|
||||
from .static import StaticHelperTest, StaticTests
|
||||
from .static import StaticHelperTest, StaticUtilsTests, StaticTests
|
||||
|
@ -2,11 +2,14 @@ from __future__ import absolute_import
|
||||
|
||||
import mimetypes
|
||||
from os import path
|
||||
import unittest
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from django.test import TestCase
|
||||
from django.http import HttpResponseNotModified
|
||||
from django.test import TestCase
|
||||
from django.utils.http import http_date
|
||||
from django.views.static import was_modified_since
|
||||
|
||||
from .. import urls
|
||||
from ..urls import media_dir
|
||||
@ -105,3 +108,14 @@ class StaticHelperTest(StaticTests):
|
||||
def tearDown(self):
|
||||
super(StaticHelperTest, self).tearDown()
|
||||
urls.urlpatterns = self._old_views_urlpatterns
|
||||
|
||||
|
||||
class StaticUtilsTests(unittest.TestCase):
|
||||
def test_was_modified_since_fp(self):
|
||||
"""
|
||||
Test that a floating point mtime does not disturb was_modified_since.
|
||||
(#18675)
|
||||
"""
|
||||
mtime = 1343416141.107817
|
||||
header = http_date(mtime)
|
||||
self.assertFalse(was_modified_since(header, mtime))
|
||||
|
Loading…
Reference in New Issue
Block a user