Commit f99a502f authored by Emanuele Aina's avatar Emanuele Aina

webhook: Fix running with no proxies

The fix to the proxy fix did break running with no proxies as ProxyFix doesn't
like being passed 0 as the number of proxies.

For this reason the unit tests were also broken. Sigh.
Signed-off-by: Emanuele Aina's avatarEmanuele Aina <emanuele.aina@collabora.com>
parent 4ff28c14
Pipeline #4154 passed with stage
in 1 minute and 35 seconds
......@@ -49,13 +49,14 @@ from flask_dance.consumer import oauth_authorized
app = Flask(__name__)
proxy_count = int(os.getenv('PROXY_COUNT') or 0)
# Handle being behind proxies that sets the X-Forwarded-For, -Host and -Proto headers.
# TODO: Switch to the werkzeug >= 0.15 pattern once it is available in Debian,
# which currently only ships 0.14
# from werkzeug.middleware.proxy_fix import ProxyFix
# app.wsgi_app = ProxyFix(app.wsgi_app, x_for=proxy_count, x_host=proxy_count, x_proto=proxy_count)
from werkzeug.contrib.fixers import ProxyFix
app.wsgi_app = ProxyFix(app.wsgi_app, num_proxies=proxy_count)
if proxy_count:
# Handle being behind proxies that sets the X-Forwarded-For, -Host and -Proto headers.
# TODO: Switch to the werkzeug >= 0.15 pattern once it is available in Debian,
# which currently only ships 0.14
# from werkzeug.middleware.proxy_fix import ProxyFix
# app.wsgi_app = ProxyFix(app.wsgi_app, x_for=proxy_count, x_host=proxy_count, x_proto=proxy_count)
from werkzeug.contrib.fixers import ProxyFix
app.wsgi_app = ProxyFix(app.wsgi_app, num_proxies=proxy_count)
# Queue of Jobs.
pending = defaultdict(set)
......
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