Allow already encoded answers

This commit is contained in:
Unrud 2017-05-07 08:17:35 +02:00
parent bc49542a62
commit f1a9cf7694

View File

@ -289,7 +289,9 @@ class Application:
headers = dict(headers) headers = dict(headers)
# Set content length # Set content length
if answer: if answer:
if hasattr(answer, "encode"):
self.logger.debug("Response content:\n%s", answer) self.logger.debug("Response content:\n%s", answer)
headers["Content-Type"] += "; charset=%s" % self.encoding
answer = answer.encode(self.encoding) answer = answer.encode(self.encoding)
accept_encoding = [ accept_encoding = [
encoding.strip() for encoding in encoding.strip() for encoding in
@ -302,7 +304,6 @@ class Application:
headers["Content-Encoding"] = "gzip" headers["Content-Encoding"] = "gzip"
headers["Content-Length"] = str(len(answer)) headers["Content-Length"] = str(len(answer))
headers["Content-Type"] += "; charset=%s" % self.encoding
# Add extra headers set in configuration # Add extra headers set in configuration
if self.configuration.has_section("headers"): if self.configuration.has_section("headers"):