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
5215c5db
Commit
5215c5db
authored
May 10, 1999
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed If-Modified-Since handling, since some clients apparently dont
handle 304 responses very well.
parent
f2a7d664
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
17 deletions
+18
-17
lib/python/App/ImageFile.py
lib/python/App/ImageFile.py
+18
-17
No files found.
lib/python/App/ImageFile.py
View file @
5215c5db
...
@@ -84,16 +84,15 @@
...
@@ -84,16 +84,15 @@
##############################################################################
##############################################################################
"""Image object that is stored in a file"""
"""Image object that is stored in a file"""
__version__
=
'$Revision: 1.2 $'
[
11
:
-
2
]
__version__
=
'$Revision: 1.3 $'
[
11
:
-
2
]
from
OFS.content_types
import
guess_content_type
from
Globals
import
package_home
from
Globals
import
package_home
from
Common
import
rfc1123_date
from
Common
import
rfc1123_date
from
string
import
rfind
,
split
from
string
import
rfind
,
split
from
DateTime
import
DateTime
from
DateTime
import
DateTime
from
time
import
time
from
time
import
time
from
os
import
stat
from
os
import
stat
import
mimetypes
import
Acquisition
import
Acquisition
...
@@ -106,31 +105,33 @@ class ImageFile(Acquisition.Explicit):
...
@@ -106,31 +105,33 @@ class ImageFile(Acquisition.Explicit):
_prefix
=
package_home
(
_prefix
)
_prefix
=
package_home
(
_prefix
)
path
=
'%s/%s'
%
(
_prefix
,
path
)
path
=
'%s/%s'
%
(
_prefix
,
path
)
self
.
path
=
path
self
.
path
=
path
content_type
,
enc
=
mimetypes
.
guess_type
(
path
)
file
=
open
(
path
,
'rb'
)
data
=
file
.
read
()
file
.
close
()
content_type
,
enc
=
guess_content_type
(
path
,
data
)
if
content_type
:
if
content_type
:
self
.
content_type
=
content_type
self
.
content_type
=
content_type
else
:
else
:
self
.
content_type
=
'image/%s'
%
path
[
rfind
(
path
,
'.'
)
+
1
:]
self
.
content_type
=
'image/%s'
%
path
[
rfind
(
path
,
'.'
)
+
1
:]
self
.
__name__
=
path
[
rfind
(
path
,
'/'
)
+
1
:]
self
.
__name__
=
path
[
rfind
(
path
,
'/'
)
+
1
:]
# Determine a reasonable last-modification time
# to support aggressive image caching.
self
.
lmt
=
float
(
stat
(
path
)[
8
])
or
time
()
self
.
lmt
=
float
(
stat
(
path
)[
8
])
or
time
()
self
.
lmh
=
rfc1123_date
(
self
.
lmt
)
self
.
lmh
=
rfc1123_date
(
self
.
lmt
)
def
_init_headers
(
self
,
request
,
response
):
def
_init_headers
(
self
,
request
,
response
):
# attempt aggressive caching!
# Waaa... trying to cache aggressively seems to cause problems :(
ms
=
request
.
get_header
(
'If-Modified-Since'
,
None
)
#
if
ms
is
not
None
:
# ms=request.get_header('If-Modified-Since', None)
# Netscape inexplicably adds a length component
# if ms is not None:
# to the IMS header. Waaaa....
# ms=split(ms, ';')[0]
ms
=
split
(
ms
,
';'
)[
0
]
# mst=DateTime(ms).timeTime()
mst
=
DateTime
(
ms
).
timeTime
()
# if mst >= self.lmt:
if
mst
>=
self
.
lmt
:
# response.setStatus(304)
response
.
setStatus
(
304
)
# return response
return
response
# response.setHeader('Expires', rfc1123_date(time()+86400.0))
response
.
setHeader
(
'Content-Type'
,
self
.
content_type
)
response
.
setHeader
(
'Content-Type'
,
self
.
content_type
)
response
.
setHeader
(
'Last-Modified'
,
self
.
lmh
)
response
.
setHeader
(
'Last-Modified'
,
self
.
lmh
)
response
.
setHeader
(
'Expires'
,
rfc1123_date
(
time
()
+
86400.0
))
def
index_html
(
self
,
REQUEST
,
RESPONSE
):
def
index_html
(
self
,
REQUEST
,
RESPONSE
):
"""Default document"""
"""Default document"""
...
...
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