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
f86588ef
Commit
f86588ef
authored
Sep 04, 2016
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small cleanup and add a WSGIRequest subclass.
parent
6199c1e4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
22 deletions
+20
-22
src/ZPublisher/WSGIPublisher.py
src/ZPublisher/WSGIPublisher.py
+20
-22
No files found.
src/ZPublisher/WSGIPublisher.py
View file @
f86588ef
...
...
@@ -124,11 +124,14 @@ def get_module_info(module_name='Zope2'):
return
info
class
WSGIRequest
(
HTTPRequest
):
"""A request object for WSGI
"""
pass
class
WSGIResponse
(
HTTPResponse
):
"""A response object for WSGI
This Response object knows nothing about ZServer, but tries to be
compatible with the ZServerHTTPResponse.
"""
_streaming
=
0
_http_version
=
None
...
...
@@ -138,24 +141,19 @@ class WSGIResponse(HTTPResponse):
after_list
=
()
def
finalize
(
self
):
headers
=
self
.
headers
body
=
self
.
body
# set 204 (no content) status if 200 and response is empty
# and not streaming
if
(
'content-type'
not
in
headers
and
'content-length'
not
in
headers
and
# Set 204 (no content) status if 200 and response is empty
# and not streaming.
if
(
'content-type'
not
in
self
.
headers
and
'content-length'
not
in
self
.
headers
and
not
self
.
_streaming
and
self
.
status
==
200
):
self
.
setStatus
(
'nocontent'
)
# add content length if not streaming
content_length
=
headers
.
get
(
'content-length'
)
# Add content length if not streaming.
content_length
=
self
.
headers
.
get
(
'content-length'
)
if
content_length
is
None
and
not
self
.
_streaming
:
self
.
setHeader
(
'content-length'
,
len
(
body
))
self
.
setHeader
(
'content-length'
,
len
(
self
.
body
))
return
'%s %s'
%
(
self
.
status
,
self
.
errmsg
),
self
.
listHeaders
(
)
return
(
'%s %s'
%
(
self
.
status
,
self
.
errmsg
),
self
.
listHeaders
()
)
def
listHeaders
(
self
):
result
=
[]
...
...
@@ -168,16 +166,16 @@ class WSGIResponse(HTTPResponse):
def
_unauthorized
(
self
):
self
.
setStatus
(
401
)
realm
=
self
.
realm
if
realm
:
self
.
setHeader
(
'WWW-Authenticate'
,
'basic realm="%s"'
%
realm
,
1
)
if
self
.
realm
:
self
.
setHeader
(
'WWW-Authenticate'
,
'basic realm="%s"'
%
self
.
realm
,
1
)
def
write
(
self
,
data
):
"""
Add data to our output stream.
"""Add data to our output stream.
HTML data may be returned using a stream-oriented interface.
This allows the browser to display partial results while
computation of a response
to proceed
.
computation of a response
proceeds
.
"""
if
not
self
.
_streaming
:
notify
(
pubevents
.
PubBeforeStreaming
(
self
))
...
...
@@ -295,7 +293,7 @@ def publish_module(environ, start_response,
_response
=
None
,
_response_factory
=
WSGIResponse
,
_request
=
None
,
_request_factory
=
HTTP
Request
,
_request_factory
=
WSGI
Request
,
_module_name
=
'Zope2'
,
):
module_info
=
get_module_info
(
_module_name
)
...
...
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