PATH_INFO might not exist if it's empty
This commit is contained in:
parent
f12dd31b4b
commit
5704b5021b
@ -334,8 +334,8 @@ class Application:
|
|||||||
status, client.responses.get(status, "Unknown"))
|
status, client.responses.get(status, "Unknown"))
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
"%s answer status for %r%s in %.3f seconds: %s",
|
"%s answer status for %r%s in %.3f seconds: %s",
|
||||||
environ["REQUEST_METHOD"], environ["PATH_INFO"], depthinfo,
|
environ["REQUEST_METHOD"], environ.get("PATH_INFO", ""),
|
||||||
(time_end - time_begin).total_seconds(), status)
|
depthinfo, (time_end - time_begin).total_seconds(), status)
|
||||||
# Return response content
|
# Return response content
|
||||||
return status, list(headers.items()), [answer] if answer else []
|
return status, list(headers.items()), [answer] if answer else []
|
||||||
|
|
||||||
@ -372,6 +372,7 @@ class Application:
|
|||||||
environ.get("SCRIPT_NAME", "")).rstrip("/")
|
environ.get("SCRIPT_NAME", "")).rstrip("/")
|
||||||
self.logger.debug("Sanitized script name: %r", environ["SCRIPT_NAME"])
|
self.logger.debug("Sanitized script name: %r", environ["SCRIPT_NAME"])
|
||||||
base_prefix = environ["SCRIPT_NAME"]
|
base_prefix = environ["SCRIPT_NAME"]
|
||||||
|
environ["PATH_INFO"] = environ.get("PATH_INFO", "")
|
||||||
# Sanitize request URI (a WSGI server indicates with an empty path,
|
# Sanitize request URI (a WSGI server indicates with an empty path,
|
||||||
# that the URL targets the application root without a trailing slash)
|
# that the URL targets the application root without a trailing slash)
|
||||||
if environ["PATH_INFO"]:
|
if environ["PATH_INFO"]:
|
||||||
|
Loading…
Reference in New Issue
Block a user