Commit 51f321d8 authored by Georgios Dagkakis's avatar Georgios Dagkakis

WSGITask: Patch should be enabled only if waitress egg is available

parent 19add837
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import ZPublisher.HTTPRequest 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): def get_environment(self):
if ZPublisher.HTTPRequest.trusted_proxies == ('0.0.0.0',): # Magic value to enable this functionality if ZPublisher.HTTPRequest.trusted_proxies == ('0.0.0.0',): # Magic value to enable this functionality
# Frontend-facing proxy is responsible for sanitising # Frontend-facing proxy is responsible for sanitising
# X_FORWARDED_FOR, and only trusted accesses should bypass # X_FORWARDED_FOR, and only trusted accesses should bypass
...@@ -21,4 +26,4 @@ def get_environment(self): ...@@ -21,4 +26,4 @@ def get_environment(self):
return environ return environ
WSGITask.get_environment = get_environment WSGITask.get_environment = get_environment
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment