Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
ef5f7ab3
Commit
ef5f7ab3
authored
May 24, 1999
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added If-Modified-Since handling.
parent
50e6f2c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
17 deletions
+25
-17
lib/python/App/ImageFile.py
lib/python/App/ImageFile.py
+12
-14
lib/python/OFS/Image.py
lib/python/OFS/Image.py
+13
-3
No files found.
lib/python/App/ImageFile.py
View file @
ef5f7ab3
...
...
@@ -84,7 +84,7 @@
##############################################################################
"""Image object that is stored in a file"""
__version__
=
'$Revision: 1.
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
from
OFS.content_types
import
guess_content_type
from
Globals
import
package_home
...
...
@@ -119,23 +119,21 @@ class ImageFile(Acquisition.Explicit):
self
.
lmh
=
rfc1123_date
(
self
.
lmt
)
def
_init_headers
(
self
,
request
,
response
):
# Waaa... trying to cache aggressively seems to cause problems :(
#
# ms=request.get_header('If-Modified-Since', None)
# if ms is not None:
# ms=split(ms, ';')[0]
# mst=DateTime(ms).timeTime()
# if mst >= self.lmt:
# response.setStatus(304)
# return response
# response.setHeader('Expires', rfc1123_date(time()+86400.0))
# Attempt to handle If-Modified-Since headers.
ms
=
request
.
get_header
(
'If-Modified-Since'
,
None
)
if
ms
is
not
None
:
ms
=
string
.
split
(
ms
,
';'
)[
0
]
ms
=
DateTime
(
ms
).
timeTime
()
if
self
.
lmt
>
ms
:
RESPONSE
.
setStatus
(
304
)
return
RESPONSE
response
.
setHeader
(
'Content-Type'
,
self
.
content_type
)
#
response.setHeader('Last-Modified', self.lmh)
response
.
setHeader
(
'Last-Modified'
,
self
.
lmh
)
def
index_html
(
self
,
REQUEST
,
RESPONSE
):
"""Default document"""
self
.
_init_headers
(
REQUEST
,
RESPONSE
)
if
self
.
_init_headers
(
REQUEST
,
RESPONSE
):
return
''
f
=
open
(
self
.
path
,
'rb'
)
data
=
f
.
read
()
f
.
close
()
...
...
lib/python/OFS/Image.py
View file @
ef5f7ab3
...
...
@@ -84,7 +84,7 @@
##############################################################################
"""Image object"""
__version__
=
'$Revision: 1.7
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.7
5
$'
[
11
:
-
2
]
import
Globals
,
string
,
struct
,
content_types
from
OFS.content_types
import
guess_content_type
...
...
@@ -170,6 +170,16 @@ class File(Persistent,Implicit,PropertyManager,
Returns the contents of the file or image. Also, sets the
Content-Type HTTP header to the objects content type.
"""
# Attempt to handle If-Modified-Since headers.
ms
=
REQUEST
.
get_header
(
'If-Modified-Since'
,
None
)
if
ms
is
not
None
:
ms
=
string
.
split
(
ms
,
';'
)[
0
]
ms
=
DateTime
(
ms
).
timeTime
()
if
self
.
_p_mtime
>
ms
:
RESPONSE
.
setStatus
(
304
)
return
RESPONSE
if
self
.
precondition
and
hasattr
(
self
,
self
.
precondition
):
# Grab whatever precondition was defined and then
# execute it. The precondition will raise an exception
...
...
@@ -179,8 +189,8 @@ class File(Persistent,Implicit,PropertyManager,
c
(
REQUEST
[
'PARENTS'
][
1
],
REQUEST
)
else
:
c
()
RESPONSE
.
setHeader
(
'
content-type'
,
self
.
content_type
)
# RESPONSE.setHeader('Last-Modified', rfc1123_date(self._p_mtime)
)
RESPONSE
.
setHeader
(
'
Last-Modified'
,
rfc1123_date
(
self
.
_p_mtime
)
)
RESPONSE
.
setHeader
(
'Content-Type'
,
self
.
content_type
)
return
self
.
data
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment