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
6945b4f5
Commit
6945b4f5
authored
Dec 06, 2001
by
Martijn Pieters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge HTP Range fix from trunk.
parent
9c9aafa1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
lib/python/OFS/Image.py
lib/python/OFS/Image.py
+12
-2
lib/python/OFS/tests/testRanges.py
lib/python/OFS/tests/testRanges.py
+11
-4
No files found.
lib/python/OFS/Image.py
View file @
6945b4f5
...
...
@@ -12,7 +12,7 @@
##############################################################################
"""Image object"""
__version__
=
'$Revision: 1.13
3
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.13
4
$'
[
11
:
-
2
]
import
Globals
,
string
,
struct
from
OFS.content_types
import
guess_content_type
...
...
@@ -171,6 +171,11 @@ class File(Persistent, Implicit, PropertyManager,
# HTTP Range header handling
range
=
REQUEST
.
get_header
(
'Range'
,
None
)
request_range
=
REQUEST
.
get_header
(
'Request-Range'
,
None
)
if
request_range
is
not
None
:
# Netscape 2 through 4 and MSIE 3 implement a draft version
# Later on, we need to serve a different mime-type as well.
range
=
request_range
if_range
=
REQUEST
.
get_header
(
'If-Range'
,
None
)
if
range
is
not
None
:
ranges
=
HTTPRangeSupport
.
parseRange
(
range
)
...
...
@@ -284,12 +289,17 @@ class File(Persistent, Implicit, PropertyManager,
end
-
start
)
# Some clients implement an earlier draft of the spec, they
# will only accept x-byteranges.
draftprefix
=
(
request_range
is
not
None
)
and
'x-'
or
''
RESPONSE
.
setHeader
(
'Content-Length'
,
size
)
RESPONSE
.
setHeader
(
'Accept-Ranges'
,
'bytes'
)
RESPONSE
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
self
.
_p_mtime
))
RESPONSE
.
setHeader
(
'Content-Type'
,
'multipart/byteranges; boundary=%s'
%
boundary
)
'multipart/%sbyteranges; boundary=%s'
%
(
draftprefix
,
boundary
))
RESPONSE
.
setStatus
(
206
)
# Partial content
pos
=
0
...
...
lib/python/OFS/tests/testRanges.py
View file @
6945b4f5
...
...
@@ -171,7 +171,7 @@ class TestRequestRange(unittest.TestCase):
'Incorrect range returned, expected %s, got %s'
%
(
`self.data[start:end]`
,
`body`
))
def
expectMultipleRanges
(
self
,
range
,
sets
,
def
expectMultipleRanges
(
self
,
range
,
sets
,
draft
=
0
,
rangeParse
=
re
.
compile
(
'bytes
\
s*(
\
d+)-(
\
d+)/(
\
d+)'
)):
req
=
self
.
app
.
REQUEST
rsp
=
req
.
RESPONSE
...
...
@@ -179,6 +179,9 @@ class TestRequestRange(unittest.TestCase):
# Add headers
req
.
environ
[
'HTTP_RANGE'
]
=
'bytes=%s'
%
range
if
draft
:
req
.
environ
[
'HTTP_REQUEST_RANGE'
]
=
'bytes=%s'
%
range
body
=
self
.
doGET
(
req
,
rsp
)
self
.
failUnless
(
rsp
.
getStatus
()
==
206
,
...
...
@@ -187,9 +190,10 @@ class TestRequestRange(unittest.TestCase):
'The Content-Range header should not be set!'
)
ct
=
string
.
split
(
rsp
.
getHeader
(
'content-type'
),
';'
)[
0
]
self
.
failIf
(
ct
!=
'multipart/byteranges'
,
"Incorrect Content-Type set. Expected 'multipart/byteranges', "
"got %s"
%
ct
)
draftprefix
=
draft
and
'x-'
or
''
self
.
failIf
(
ct
!=
'multipart/%sbyteranges'
%
draftprefix
,
"Incorrect Content-Type set. Expected 'multipart/%sbyteranges', "
"got %s"
%
(
draftprefix
,
ct
))
if
rsp
.
getHeader
(
'content-length'
):
self
.
failIf
(
rsp
.
getHeader
(
'content-length'
)
!=
len
(
body
),
'Incorrect Content-Length is set! Expected %d, got %d.'
%
(
...
...
@@ -304,6 +308,9 @@ class TestRequestRange(unittest.TestCase):
def
testMultipleRanges
(
self
):
self
.
expectMultipleRanges
(
'3-7,10-15'
,
[(
3
,
8
),
(
10
,
16
)])
def
testMultipleRangesDraft
(
self
):
self
.
expectMultipleRanges
(
'3-7,10-15'
,
[(
3
,
8
),
(
10
,
16
)],
draft
=
1
)
def
testMultipleRangesBigFile
(
self
):
self
.
uploadBigFile
()
self
.
expectMultipleRanges
(
'3-700,10-15,-10000'
,
...
...
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