Ticket #5064: use_base_url_for_redirect-r6199.diff
| File use_base_url_for_redirect-r6199.diff, 2.7 KB (added by cboos, 5 years ago) |
|---|
-
trac/env.py
80 80 (''since 0.11'')""") 81 81 82 82 base_url = Option('trac', 'base_url', '', 83 """Reference URL for the Trac deployment. 84 85 This is the address that will be used when producing documents 86 outside of the web browsing context, in order to produce canonical 87 URLs. 88 89 For example, this is the address that will be used in notification 90 mails.""") 91 92 base_url_for_redirect = BoolOption('trac', 'use_base_url_for_redirect', 93 False, 83 94 """Base URL of the Trac deployment. 84 95 85 In most configurations, Trac willautomatically reconstruct the URL96 In some configurations, Trac can't automatically reconstruct the URL 86 97 that is used to access it automatically. However, in more complex 87 98 setups, usually involving running Trac behind a HTTP proxy, you may 88 need to use this option to force Trac to use the correct URL.""") 99 need to use this option to force Trac to use the base_url also for 100 redirects. This introduces the obvious limitation that the environment 101 will become usable only from that host, as redirects are quite 102 frequent.""") 89 103 90 104 project_name = Option('project', 'name', 'My Project', 91 105 """Name of the project.""") -
trac/web/api.py
276 276 277 277 self.send_response(status) 278 278 if not url.startswith('http://') and not url.startswith('https://'): 279 # Make sure the URL is absolute, honor base_url for 280 # scheme and host if present 279 # Make sure the URL is absolute 281 280 scheme, host = urlparse.urlparse(self.base_url)[:2] 282 url = urlparse.urlunparse((scheme, host, url, None, None, None)) 281 url = urlparse.urlunparse((scheme, host, url, None, None, None)) 283 282 284 283 self.send_header('Location', url) 285 284 self.send_header('Content-Type', 'text/plain') -
trac/web/main.py
371 371 env = env_error = None 372 372 try: 373 373 env = open_environment(env_path, use_cache=not run_once) 374 if env.base_url :374 if env.base_url_for_redirect: 375 375 environ['trac.base_url'] = env.base_url 376 376 except TracError, e: 377 377 env_error = e
