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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rafael Monnerat
erp5
Commits
51f321d8
Commit
51f321d8
authored
Jan 29, 2021
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WSGITask: Patch should be enabled only if waitress egg is available
parent
19add837
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
15 deletions
+20
-15
product/ERP5Type/patches/WSGITask.py
product/ERP5Type/patches/WSGITask.py
+20
-15
No files found.
product/ERP5Type/patches/WSGITask.py
View file @
51f321d8
# -*- coding: utf-8 -*-
import
ZPublisher.HTTPRequest
from
waitress.task
import
WSGITask
try
:
from
waitress.task
import
WSGITask
except
ImportError
:
WSGITask
=
None
WSGITask_get_environment
=
WSGITask
.
get_environment
# Patch should be enabled only if waitress egg is available
if
WSGITask
is
not
None
:
WSGITask_get_environment
=
WSGITask
.
get_environment
def
get_environment
(
self
):
if
ZPublisher
.
HTTPRequest
.
trusted_proxies
==
(
'0.0.0.0'
,):
# Magic value to enable this functionality
# Frontend-facing proxy is responsible for sanitising
# X_FORWARDED_FOR, and only trusted accesses should bypass
# that proxy. So trust first entry.
forwarded_for
=
dict
(
self
.
request
.
headers
).
get
(
'X_FORWARDED_FOR'
,
''
).
split
(
','
,
1
)[
0
].
strip
()
else
:
forwarded_for
=
None
def
get_environment
(
self
):
if
ZPublisher
.
HTTPRequest
.
trusted_proxies
==
(
'0.0.0.0'
,):
# Magic value to enable this functionality
# Frontend-facing proxy is responsible for sanitising
# X_FORWARDED_FOR, and only trusted accesses should bypass
# that proxy. So trust first entry.
forwarded_for
=
dict
(
self
.
request
.
headers
).
get
(
'X_FORWARDED_FOR'
,
''
).
split
(
','
,
1
)[
0
].
strip
()
else
:
forwarded_for
=
None
environ
=
WSGITask_get_environment
(
self
)
environ
=
WSGITask_get_environment
(
self
)
if
forwarded_for
:
environ
[
'REMOTE_HOST'
]
=
environ
[
'REMOTE_ADDR'
]
=
forwarded_for
if
forwarded_for
:
environ
[
'REMOTE_HOST'
]
=
environ
[
'REMOTE_ADDR'
]
=
forwarded_for
return
environ
return
environ
WSGITask
.
get_environment
=
get_environment
WSGITask
.
get_environment
=
get_environment
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