Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
141
Merge Requests
141
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
dff53681
Commit
dff53681
authored
Jun 04, 2012
by
Romain Courteaud
Committed by
Sebastien Robin
Aug 07, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get modification date from btree.
Support no content.
parent
00f696ee
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
12 deletions
+23
-12
product/ERP5/Document/BigFile.py
product/ERP5/Document/BigFile.py
+23
-12
No files found.
product/ERP5/Document/BigFile.py
View file @
dff53681
...
...
@@ -123,6 +123,8 @@ class BigFile(File):
if
range
is
not
None
:
ranges
=
HTTPRangeSupport
.
parseRange
(
range
)
data
=
self
.
_baseGetData
()
if
if_range
is
not
None
:
# Only send ranges if the data isn't modified, otherwise send
# the whole object. Support both ETags and Last-Modified dates!
...
...
@@ -139,6 +141,9 @@ class BigFile(File):
try
:
mod_since
=
long
(
DateTime
(
date
).
timeTime
())
except
:
mod_since
=
None
if
mod_since
is
not
None
:
if
data
is
not
None
:
last_mod
=
long
(
data
.
_p_mtime
)
else
:
if
self
.
_p_mtime
:
last_mod
=
long
(
self
.
_p_mtime
)
else
:
...
...
@@ -161,8 +166,10 @@ class BigFile(File):
RESPONSE
.
setHeader
(
'Content-Range'
,
'bytes */%d'
%
self
.
getSize
())
RESPONSE
.
setHeader
(
'Accept-Ranges'
,
'bytes'
)
RESPONSE
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
self
.
_p_mtime
))
if
data
is
not
None
:
RESPONSE
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
data
.
_p_mtime
))
else
:
RESPONSE
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
self
.
_p_mtime
))
RESPONSE
.
setHeader
(
'Content-Type'
,
self
.
content_type
)
RESPONSE
.
setHeader
(
'Content-Length'
,
self
.
getSize
())
RESPONSE
.
setStatus
(
416
)
...
...
@@ -175,8 +182,10 @@ class BigFile(File):
start
,
end
=
ranges
[
0
]
size
=
end
-
start
RESPONSE
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
self
.
_p_mtime
))
if
data
is
not
None
:
RESPONSE
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
data
.
_p_mtime
))
else
:
RESPONSE
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
self
.
_p_mtime
))
RESPONSE
.
setHeader
(
'Content-Type'
,
self
.
content_type
)
RESPONSE
.
setHeader
(
'Content-Length'
,
size
)
RESPONSE
.
setHeader
(
'Accept-Ranges'
,
'bytes'
)
...
...
@@ -184,7 +193,6 @@ class BigFile(File):
'bytes %d-%d/%d'
%
(
start
,
end
-
1
,
self
.
getSize
()))
RESPONSE
.
setStatus
(
206
)
# Partial content
data
=
self
.
_baseGetData
()
if
isinstance
(
data
,
str
):
RESPONSE
.
write
(
data
[
start
:
end
])
return
True
...
...
@@ -209,6 +217,7 @@ class BigFile(File):
size
=
(
size
+
len
(
'%d%d'
%
(
start
,
end
-
1
))
+
end
-
start
)
data
=
self
.
_baseGetData
()
# Some clients implement an earlier draft of the spec, they
# will only accept x-byteranges.
...
...
@@ -216,15 +225,15 @@ class BigFile(File):
RESPONSE
.
setHeader
(
'Content-Length'
,
size
)
RESPONSE
.
setHeader
(
'Accept-Ranges'
,
'bytes'
)
RESPONSE
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
self
.
_p_mtime
))
if
data
is
not
None
:
RESPONSE
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
data
.
_p_mtime
))
else
:
RESPONSE
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
self
.
_p_mtime
))
RESPONSE
.
setHeader
(
'Content-Type'
,
'multipart/%sbyteranges; boundary=%s'
%
(
draftprefix
,
boundary
))
RESPONSE
.
setStatus
(
206
)
# Partial content
data
=
self
.
_baseGetData
()
for
start
,
end
in
ranges
:
RESPONSE
.
write
(
'
\
r
\
n
--%s
\
r
\
n
'
%
boundary
)
RESPONSE
.
write
(
'Content-Type: %s
\
r
\
n
'
%
...
...
@@ -285,6 +294,8 @@ class BigFile(File):
RESPONSE
.
setHeader
(
'Accept-Ranges'
,
'bytes'
)
if
data
is
None
:
return
''
iterator
=
data
.
iterate
()
try
:
while
1
:
...
...
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