From ca9b5695f07ca50790ce7398e77b04e4c97f168c Mon Sep 17 00:00:00 2001
From: Simon Charette <charette.s@gmail.com>
Date: Fri, 27 Jul 2012 15:28:09 -0400
Subject: [PATCH] Fixed #18675 -- Make sure if-modified-since works on 64
oses.
---
django/views/static.py | 2 +-
.../conditional_processing/models.py | 11 ++++++++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/django/views/static.py b/django/views/static.py
index bcac947..bb1dcfd 100644
|
a
|
b
|
def was_modified_since(header=None, mtime=0, size=0):
|
| 138 | 138 | header_len = matches.group(3) |
| 139 | 139 | if header_len and int(header_len) != size: |
| 140 | 140 | raise ValueError |
| 141 | | if mtime > header_mtime: |
| | 141 | if int(mtime) > header_mtime: |
| 142 | 142 | raise ValueError |
| 143 | 143 | except (AttributeError, ValueError, OverflowError): |
| 144 | 144 | return True |
diff --git a/tests/regressiontests/conditional_processing/models.py b/tests/regressiontests/conditional_processing/models.py
index d1a8ac6..5487276 100644
|
a
|
b
|
from datetime import datetime
|
| 3 | 3 | |
| 4 | 4 | from django.test import TestCase |
| 5 | 5 | from django.utils import unittest |
| 6 | | from django.utils.http import parse_etags, quote_etag, parse_http_date |
| | 6 | from django.utils.http import http_date, parse_etags, parse_http_date, quote_etag |
| | 7 | from django.views.static import was_modified_since |
| 7 | 8 | |
| 8 | 9 | |
| 9 | 10 | FULL_RESPONSE = 'Test conditional get response' |
| … |
… |
class HttpDateProcessing(unittest.TestCase):
|
| 154 | 155 | parsed = parse_http_date('Sun Nov 6 08:49:37 1994') |
| 155 | 156 | self.assertEqual(datetime.utcfromtimestamp(parsed), |
| 156 | 157 | datetime(1994, 11, 6, 8, 49, 37)) |
| | 158 | |
| | 159 | |
| | 160 | class WasModifiedSince(unittest.TestCase): |
| | 161 | def test_floating_point_mtime(self): |
| | 162 | # See #18675 |
| | 163 | mtime = 1343416141.107817 |
| | 164 | header = http_date(mtime) |
| | 165 | self.assertFalse(was_modified_since(header, mtime)) |