diff --git a/pywb/apps/frontendapp.py b/pywb/apps/frontendapp.py index 3ab74bfc..956805eb 100644 --- a/pywb/apps/frontendapp.py +++ b/pywb/apps/frontendapp.py @@ -641,8 +641,8 @@ class FrontEndApp(object): urls = self.url_map.bind_to_environ(environ) try: endpoint, args = urls.match() - # store original script_name (original prefix) before modifications are made - environ['pywb.app_prefix'] = environ.get('SCRIPT_NAME', '') + + self.rewriterapp.prepare_env(environ) # store original script_name (original prefix) before modifications are made environ['ORIG_SCRIPT_NAME'] = environ.get('SCRIPT_NAME') diff --git a/pywb/apps/rewriterapp.py b/pywb/apps/rewriterapp.py index ca5aa9d5..8123cf95 100644 --- a/pywb/apps/rewriterapp.py +++ b/pywb/apps/rewriterapp.py @@ -303,15 +303,24 @@ class RewriterApp(object): return resp - def render_content(self, wb_url, kwargs, environ): - wb_url = wb_url.replace('#', '%23') - wb_url = WbUrl(wb_url) + def prepare_env(self, environ): + """ setup environ path prefixes and scheme """ + if 'pywb.host_prefix' in environ: + return proto = environ.get('HTTP_X_FORWARDED_PROTO', self.force_scheme) if proto: environ['wsgi.url_scheme'] = proto + environ['pywb.host_prefix'] = self.get_host_prefix(environ) + environ['pywb.app_prefix'] = environ.get('SCRIPT_NAME', '') + environ['pywb.static_prefix'] = environ['pywb.host_prefix'] + environ['pywb.app_prefix'] + '/' + self.static_prefix + + def render_content(self, wb_url, kwargs, environ): + wb_url = wb_url.replace('#', '%23') + wb_url = WbUrl(wb_url) + history_page = environ.pop('HTTP_X_WOMBAT_HISTORY_PAGE', '') if history_page: wb_url.url = history_page @@ -321,13 +330,13 @@ class RewriterApp(object): is_timegate = self._check_accept_dt(wb_url, environ) - host_prefix = self.get_host_prefix(environ) + self.prepare_env(environ) + + host_prefix = environ['pywb.host_prefix'] rel_prefix = self.get_rel_prefix(environ) full_prefix = host_prefix + rel_prefix - environ['pywb.host_prefix'] = host_prefix - pywb_static_prefix = host_prefix + environ.get('pywb.app_prefix', '') + '/' + self.static_prefix - environ['pywb.static_prefix'] = pywb_static_prefix - pywb_static_prefix += '/' + + pywb_static_prefix = environ['pywb.static_prefix'] + '/' is_proxy = ('wsgiprox.proxy_host' in environ) # if OPTIONS in proxy mode, just generate the proxy responss diff --git a/pywb/version.py b/pywb/version.py index e1e6add7..1fe20f2e 100644 --- a/pywb/version.py +++ b/pywb/version.py @@ -1,4 +1,4 @@ -__version__ = '2.6.2' +__version__ = '2.6.3' if __name__ == '__main__': print(__version__) diff --git a/tests/test_integration.py b/tests/test_integration.py index acfef645..f5abf5f0 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -12,12 +12,25 @@ class TestWbIntegration(BaseConfigTest): def test_home(self): resp = self.testapp.get('/') self._assert_basic_html(resp) + assert '