##// END OF EJS Templates
uncompress compressed data
Ian Castleden -
Show More
@@ -661,12 +661,21 b' class DisplayObject(object):'
661 661 data = response.read()
662 662 # extract encoding from header, if there is one:
663 663 encoding = None
664 if "content-type" in response.headers:
664 if 'content-type' in response.headers:
665 665 for sub in response.headers['content-type'].split(';'):
666 666 sub = sub.strip()
667 667 if sub.startswith('charset'):
668 668 encoding = sub.split('=')[-1].strip()
669 669 break
670 if 'content-encoding' in response.headers:
671 # TODO: do deflate?
672 if 'gzip' in response.headers['content-encoding']:
673 import gzip
674 from io import BytesIO
675 with gzip.open(BytesIO(data), 'rt', encoding=encoding) as fp:
676 encoding = None
677 data = fp.read()
678
670 679 # decode data, if an encoding was specified
671 680 # We only touch self.data once since
672 681 # subclasses such as SVG have @data.setter methods
General Comments 0
You need to be logged in to leave comments. Login now