Show More
@@ -661,12 +661,21 b' class DisplayObject(object):' | |||||
661 | data = response.read() |
|
661 | data = response.read() | |
662 | # extract encoding from header, if there is one: |
|
662 | # extract encoding from header, if there is one: | |
663 | encoding = None |
|
663 | encoding = None | |
664 |
if |
|
664 | if 'content-type' in response.headers: | |
665 | for sub in response.headers['content-type'].split(';'): |
|
665 | for sub in response.headers['content-type'].split(';'): | |
666 | sub = sub.strip() |
|
666 | sub = sub.strip() | |
667 | if sub.startswith('charset'): |
|
667 | if sub.startswith('charset'): | |
668 | encoding = sub.split('=')[-1].strip() |
|
668 | encoding = sub.split('=')[-1].strip() | |
669 | break |
|
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 | # decode data, if an encoding was specified |
|
679 | # decode data, if an encoding was specified | |
671 | # We only touch self.data once since |
|
680 | # We only touch self.data once since | |
672 | # subclasses such as SVG have @data.setter methods |
|
681 | # subclasses such as SVG have @data.setter methods |
General Comments 0
You need to be logged in to leave comments.
Login now