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
5e26679d
Commit
5e26679d
authored
Jun 16, 2015
by
Gerhard Weis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support IStreamIterator as WSGI response body
parent
b50d5bbf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletion
+27
-1
src/ZPublisher/WSGIPublisher.py
src/ZPublisher/WSGIPublisher.py
+5
-1
src/ZPublisher/tests/test_WSGIPublisher.py
src/ZPublisher/tests/test_WSGIPublisher.py
+22
-0
No files found.
src/ZPublisher/WSGIPublisher.py
View file @
5e26679d
...
@@ -131,12 +131,16 @@ class WSGIResponse(HTTPResponse):
...
@@ -131,12 +131,16 @@ class WSGIResponse(HTTPResponse):
self
.
stdout
.
write
(
data
)
self
.
stdout
.
write
(
data
)
def
setBody
(
self
,
body
,
title
=
''
,
is_error
=
0
):
def
setBody
(
self
,
body
,
title
=
''
,
is_error
=
0
):
if
isinstance
(
body
,
file
)
or
IStreamIterator
.
providedBy
(
body
)
:
if
isinstance
(
body
,
file
):
body
.
seek
(
0
,
2
)
body
.
seek
(
0
,
2
)
length
=
body
.
tell
()
length
=
body
.
tell
()
body
.
seek
(
0
)
body
.
seek
(
0
)
self
.
setHeader
(
'Content-Length'
,
'%d'
%
length
)
self
.
setHeader
(
'Content-Length'
,
'%d'
%
length
)
self
.
body
=
body
self
.
body
=
body
elif
IStreamIterator
.
providedBy
(
body
):
self
.
body
=
body
self
.
_streaming
=
1
HTTPResponse
.
setBody
(
self
,
''
,
title
,
is_error
)
else
:
else
:
HTTPResponse
.
setBody
(
self
,
body
,
title
,
is_error
)
HTTPResponse
.
setBody
(
self
,
body
,
title
,
is_error
)
...
...
src/ZPublisher/tests/test_WSGIPublisher.py
View file @
5e26679d
...
@@ -136,6 +136,28 @@ class WSGIResponseTests(unittest.TestCase):
...
@@ -136,6 +136,28 @@ class WSGIResponseTests(unittest.TestCase):
time
.
gmtime
(
time
.
mktime
(
WHEN
)))
time
.
gmtime
(
time
.
mktime
(
WHEN
)))
self
.
assertTrue
((
'Date'
,
whenstr
)
in
headers
)
self
.
assertTrue
((
'Date'
,
whenstr
)
in
headers
)
def
test_setBody_IStreamIterator
(
self
):
from
ZPublisher.Iterators
import
IStreamIterator
from
zope.interface
import
implements
class
test_streamiterator
:
implements
(
IStreamIterator
)
data
=
"hello"
done
=
0
def
next
(
self
):
if
not
self
.
done
:
self
.
done
=
1
return
self
.
data
raise
StopIteration
response
=
self
.
_makeOne
()
response
.
setStatus
(
200
)
body
=
test_streamiterator
()
response
.
setBody
(
body
)
response
.
finalize
()
self
.
assertTrue
(
body
is
response
.
body
)
#def test___str__already_wrote_not_chunking(self):
#def test___str__already_wrote_not_chunking(self):
# response = self._makeOne()
# response = self._makeOne()
# response._wrote = True
# response._wrote = True
...
...
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