commit
a60e224ccf
@ -33,6 +33,7 @@ import socket
|
|||||||
import ssl
|
import ssl
|
||||||
import wsgiref.simple_server
|
import wsgiref.simple_server
|
||||||
import re
|
import re
|
||||||
|
import zlib
|
||||||
from http import client
|
from http import client
|
||||||
from urllib.parse import unquote, urlparse
|
from urllib.parse import unquote, urlparse
|
||||||
|
|
||||||
@ -314,6 +315,13 @@ class Application:
|
|||||||
if answer:
|
if answer:
|
||||||
self.logger.debug("Response content:\n%s" % answer, environ)
|
self.logger.debug("Response content:\n%s" % answer, environ)
|
||||||
answer = answer.encode(self.encoding)
|
answer = answer.encode(self.encoding)
|
||||||
|
accept_encoding = [
|
||||||
|
encoding.strip() for encoding in
|
||||||
|
environ.get("HTTP_ACCEPT_ENCODING", "").split(",")
|
||||||
|
if encoding.strip()]
|
||||||
|
if "deflate" in accept_encoding:
|
||||||
|
answer = zlib.compress(answer)
|
||||||
|
headers["Content-Encoding"] = "deflate"
|
||||||
headers["Content-Length"] = str(len(answer))
|
headers["Content-Length"] = str(len(answer))
|
||||||
|
|
||||||
if self.configuration.has_section("headers"):
|
if self.configuration.has_section("headers"):
|
||||||
|
Loading…
Reference in New Issue
Block a user