Compress answer
The protocol uses verbose XML and compression reduces the size significantly.
This commit is contained in:
parent
8ebd3810b5
commit
a24613da9c
@ -33,6 +33,7 @@ import socket
|
||||
import ssl
|
||||
import wsgiref.simple_server
|
||||
import re
|
||||
import zlib
|
||||
from http import client
|
||||
from urllib.parse import unquote, urlparse
|
||||
|
||||
@ -314,6 +315,13 @@ class Application:
|
||||
if answer:
|
||||
self.logger.debug("Response content:\n%s" % answer, environ)
|
||||
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))
|
||||
|
||||
if self.configuration.has_section("headers"):
|
||||
|
Loading…
Reference in New Issue
Block a user