Allow already encoded answers
This commit is contained in:
parent
bc49542a62
commit
f1a9cf7694
@ -289,8 +289,10 @@ class Application:
|
|||||||
headers = dict(headers)
|
headers = dict(headers)
|
||||||
# Set content length
|
# Set content length
|
||||||
if answer:
|
if answer:
|
||||||
self.logger.debug("Response content:\n%s", answer)
|
if hasattr(answer, "encode"):
|
||||||
answer = answer.encode(self.encoding)
|
self.logger.debug("Response content:\n%s", answer)
|
||||||
|
headers["Content-Type"] += "; charset=%s" % self.encoding
|
||||||
|
answer = answer.encode(self.encoding)
|
||||||
accept_encoding = [
|
accept_encoding = [
|
||||||
encoding.strip() for encoding in
|
encoding.strip() for encoding in
|
||||||
environ.get("HTTP_ACCEPT_ENCODING", "").split(",")
|
environ.get("HTTP_ACCEPT_ENCODING", "").split(",")
|
||||||
@ -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"):
|
||||||
|
Loading…
Reference in New Issue
Block a user