Cosmetics

This commit is contained in:
Guillaume Ayoub 2017-02-26 16:19:38 +01:00
parent e6880057a2
commit 46fcec8fe0

View File

@ -299,7 +299,10 @@ class Application:
time_end = datetime.datetime.now() time_end = datetime.datetime.now()
status = "%i %s" % ( status = "%i %s" % (
status, client.responses.get(status, "Unknown")) status, client.responses.get(status, "Unknown"))
self.logger.info("%s answer status for %s in %s sec: %s", environ["REQUEST_METHOD"], environ["PATH_INFO"] + depthinfo, (time_end - time_begin).total_seconds(), status) self.logger.info(
"%s answer status for %s in %s sec: %s",
environ["REQUEST_METHOD"], environ["PATH_INFO"] + depthinfo,
(time_end - time_begin).total_seconds(), status)
start_response(status, list(headers.items())) start_response(status, list(headers.items()))
# Return response content # Return response content
return [answer] if answer else [] return [answer] if answer else []
@ -320,16 +323,19 @@ class Application:
if environ["HTTP_DEPTH"]: if environ["HTTP_DEPTH"]:
depthinfo = " with depth " + environ["HTTP_DEPTH"] depthinfo = " with depth " + environ["HTTP_DEPTH"]
time_begin = datetime.datetime.now() time_begin = datetime.datetime.now()
self.logger.info("%s request for %s received from %s using \"%s\"", self.logger.info(
environ["REQUEST_METHOD"], environ["PATH_INFO"] + depthinfo, remote_host, remote_useragent) "%s request for %s received from %s using \"%s\"",
environ["REQUEST_METHOD"], environ["PATH_INFO"] + depthinfo,
remote_host, remote_useragent)
headers = pprint.pformat(self.headers_log(environ)) headers = pprint.pformat(self.headers_log(environ))
self.logger.debug("Request headers:\n%s", headers) self.logger.debug("Request headers:\n%s", headers)
# Let reverse proxies overwrite SCRIPT_NAME # Let reverse proxies overwrite SCRIPT_NAME
if "HTTP_X_SCRIPT_NAME" in environ: if "HTTP_X_SCRIPT_NAME" in environ:
environ["SCRIPT_NAME"] = environ["HTTP_X_SCRIPT_NAME"] environ["SCRIPT_NAME"] = environ["HTTP_X_SCRIPT_NAME"]
self.logger.debug("Script name overwritten by client: %s", self.logger.debug(
environ["SCRIPT_NAME"]) "Script name overwritten by client: %s",
environ["SCRIPT_NAME"])
# Sanitize base prefix # Sanitize base prefix
environ["SCRIPT_NAME"] = storage.sanitize_path( environ["SCRIPT_NAME"] = storage.sanitize_path(
environ.get("SCRIPT_NAME", "")).rstrip("/") environ.get("SCRIPT_NAME", "")).rstrip("/")