summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTres Seaver <tseaver@palladion.com>2014-03-10 11:44:12 -0400
committerTres Seaver <tseaver@palladion.com>2014-03-10 11:44:12 -0400
commit486315c33ecbbc19f29a8947615e8ecabfc6ad6c (patch)
tree78efdf7504eb2145936322af9ee1390e73e3e8b5
parent649b1aa2542c34736ad8da91bfb6de14e907602b (diff)
downloadwaitress-486315c33ecbbc19f29a8947615e8ecabfc6ad6c.tar.gz
Add 'trusted_proxy' adjustment.
-rw-r--r--waitress/adjustments.py4
-rw-r--r--waitress/tests/test_adjustments.py2
2 files changed, 6 insertions, 0 deletions
diff --git a/waitress/adjustments.py b/waitress/adjustments.py
index 2835e97..d5b237b 100644
--- a/waitress/adjustments.py
+++ b/waitress/adjustments.py
@@ -52,6 +52,7 @@ class Adjustments(object):
('host', str),
('port', int),
('threads', int),
+ ('trusted_proxy', str),
('url_scheme', str),
('url_prefix', slash_fixed_str),
('backlog', int),
@@ -84,6 +85,9 @@ class Adjustments(object):
# mumber of threads available for tasks
threads = 4
+ # Host allowed to overrid ``wsgi.url_scheme`` via header
+ trusted_proxy = None
+
# default ``wsgi.url_scheme`` value
url_scheme = 'http'
diff --git a/waitress/tests/test_adjustments.py b/waitress/tests/test_adjustments.py
index 736cf50..f2b28c2 100644
--- a/waitress/tests/test_adjustments.py
+++ b/waitress/tests/test_adjustments.py
@@ -54,6 +54,7 @@ class TestAdjustments(unittest.TestCase):
host='host',
port='8080',
threads='5',
+ trusted_proxy='192.168.1.1',
url_scheme='https',
backlog='20',
recv_bytes='200',
@@ -77,6 +78,7 @@ class TestAdjustments(unittest.TestCase):
self.assertEqual(inst.host, 'host')
self.assertEqual(inst.port, 8080)
self.assertEqual(inst.threads, 5)
+ self.assertEqual(inst.trusted_proxy, '192.168.1.1')
self.assertEqual(inst.url_scheme, 'https')
self.assertEqual(inst.backlog, 20)
self.assertEqual(inst.recv_bytes, 200)