You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by ke...@apache.org on 2022/02/18 19:38:05 UTC
[allura] 02/03: 301 instead of 302 for http/https redirects
This is an automated email from the ASF dual-hosted git repository.
kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 549d0ee483140a23a4d31f36dd8d4efa67c8c6fc
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Fri Feb 18 13:54:12 2022 -0500
301 instead of 302 for http/https redirects
---
Allura/allura/lib/custom_middleware.py | 4 ++--
Allura/allura/tests/functional/test_root.py | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/Allura/allura/lib/custom_middleware.py b/Allura/allura/lib/custom_middleware.py
index 25b31bf..31e7200 100644
--- a/Allura/allura/lib/custom_middleware.py
+++ b/Allura/allura/lib/custom_middleware.py
@@ -264,9 +264,9 @@ class SSLMiddleware(object):
# and we don't want to do any redirects within that sub-request
pass
elif not secure and force_ssl:
- resp = exc.HTTPFound(location='https://' + srv_path)
+ resp = exc.HTTPMovedPermanently(location='https://' + srv_path)
elif secure and not force_ssl:
- resp = exc.HTTPFound(location='http://' + srv_path)
+ resp = exc.HTTPMovedPermanently(location='http://' + srv_path)
if not resp:
resp = self.app
return resp(environ, start_response)
diff --git a/Allura/allura/tests/functional/test_root.py b/Allura/allura/tests/functional/test_root.py
index 31efd55..8804397 100644
--- a/Allura/allura/tests/functional/test_root.py
+++ b/Allura/allura/tests/functional/test_root.py
@@ -206,4 +206,5 @@ class TestRootWithSSLPattern(TestController):
extra_environ={'wsgi.url_scheme': str('https')},
status=404)
assert '302 Found' not in r.text, r.text
+ assert '301 Moved Permanently' not in r.text, r.text
assert '/error/document' not in r.text, r.text