1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-09-15 20:36:55 +00:00

Extract httputils.redirect

This commit is contained in:
Unrud 2022-01-18 18:20:15 +01:00
parent 1336c02079
commit d1532aa466
4 changed files with 10 additions and 12 deletions

View file

@ -197,10 +197,8 @@ class Application(ApplicationPartDelete, ApplicationPartHead,
location = base_prefix + path
logger.info("Redirecting to sanitized path: %r ==> %r",
base_prefix + unsafe_path, location)
return response(
client.MOVED_PERMANENTLY,
{"Location": location, "Content-Type": "text/plain"},
"Redirected to %s" % location)
return response(*httputils.redirect(
location, client.MOVED_PERMANENTLY))
logger.debug("Sanitized path: %r", path)
# Get function corresponding to method

View file

@ -62,10 +62,7 @@ class ApplicationPartGet(ApplicationBase):
"""Manage GET request."""
# Redirect to .web if the root URL is requested
if not pathutils.strip_path(path):
location = ".web"
return (client.FOUND,
{"Location": location, "Content-Type": "text/plain"},
"Redirected to %s" % location)
return httputils.redirect(".web")
# Dispatch .web URL to web module
if path == "/.web" or path.startswith("/.web/"):
return self._web.get(environ, base_prefix, path, user)