Use length of encoded error response

This is purely cosmetic. The lengths are the same, because it gets encoded as ASCII.
This commit is contained in:
Unrud 2017-08-24 14:34:29 +02:00
parent 4cfe92cf50
commit 36bca799e1

View File

@ -327,10 +327,11 @@ class Application:
self.logger.error("An exception occurred during %s request on %r: "
"%s", method, path, e, exc_info=True)
status, headers, answer = INTERNAL_SERVER_ERROR
answer = answer.encode("ascii")
status = "%d %s" % (
status, client.responses.get(status, "Unknown"))
headers = [("Content-Length", str(len(answer)))] + list(headers)
answers = [answer.encode("ascii")]
answers = [answer]
start_response(status, headers)
return answers