From c17e166f5f71d2e44e319eaa8e7e3f81e68de3bf Mon Sep 17 00:00:00 2001 From: Marcin Kuzminski Date: Wed, 26 Jul 2017 16:19:06 +0200 Subject: [PATCH] events: make sure we propagate our dummy request with proper application_url. - handles proper proxy prefix - handles https and reverse proxies --- rhodecode/lib/base.py | 8 ++++++-- rhodecode/lib/hooks_daemon.py | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/rhodecode/lib/base.py b/rhodecode/lib/base.py index a4c79cca..85573aae 100644 --- a/rhodecode/lib/base.py +++ b/rhodecode/lib/base.py @@ -605,9 +605,13 @@ def add_events_routes(config): pattern='/{repo_name}/files/{commit_id}/{f_path}') -def bootstrap_request(): +def bootstrap_request(**kwargs): import pyramid.testing - request = pyramid.testing.DummyRequest() + request = pyramid.testing.DummyRequest(**kwargs) + request.application_url = kwargs.pop('application_url', 'http://example.com') + request.host = kwargs.pop('host', 'example.com:80') + request.domain = kwargs.pop('domain', 'example.com') + config = pyramid.testing.setUp(request=request) add_events_routes(config) diff --git a/rhodecode/lib/hooks_daemon.py b/rhodecode/lib/hooks_daemon.py index 2c200946..ed4005a5 100644 --- a/rhodecode/lib/hooks_daemon.py +++ b/rhodecode/lib/hooks_daemon.py @@ -207,7 +207,9 @@ class Hooks(object): def _call_hook(self, hook, extras): extras = AttributeDict(extras) - extras.request = bootstrap_request() + + extras.request = bootstrap_request( + application_url=extras['server_url']) try: result = hook(extras)