File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -207,6 +207,13 @@ def content_type(self):
207207 return get_content_type_from_headers (self .response .headers )
208208 return ''
209209
210+ @cached_property
211+ def content_encoding (self ):
212+ """Returns an encoding (usually a compression algorithm) of this resource if available."""
213+ if self .response is not None and 'Content-Encoding' in self .response .headers :
214+ return self .response .headers ['Content-Encoding' ]
215+ return ''
216+
210217 @cached_property
211218 def url (self ):
212219 """Returns the actual url of this resource which is resolved if
@@ -255,6 +262,14 @@ def viewing_js(self):
255262 """Checks whether the current resource is a javascript type or not."""
256263 return self .content_type in self .js_content_types
257264
265+ svg_content_types = tuple ([
266+ 'image/svg+xml'
267+ ])
268+
269+ def viewing_svg (self ):
270+ """Checks whether the current resource is a svg type or not."""
271+ return self .content_type in self .svg_content_types
272+
258273 def set_response (self , response ):
259274 """Update the response attribute of this object.
260275
@@ -384,6 +399,8 @@ def _retrieve(self):
384399 "Response object for url <%s> has no attribute 'raw'!"
385400 % self .url )
386401 content = BytesIO (self .response .content )
402+ elif self .viewing_svg () and self .content_encoding == 'gzip' :
403+ content = BytesIO (self .response .content )
387404 else :
388405 content = self .response .raw
389406
You can’t perform that action at this time.
0 commit comments