a file-like object to decode a response encoded with the gzip method, as described in RFC 1952.
| 1063 | # @return a file-like object that the decoded data can be read() from |
| 1064 | |
| 1065 | class GzipDecodedResponse(gzip.GzipFile if gzip else object): |
| 1066 | """a file-like object to decode a response encoded with the gzip |
| 1067 | method, as described in RFC 1952. |
| 1068 | """ |
| 1069 | def __init__(self, response): |
| 1070 | #response doesn't support tell() and read(), required by |
| 1071 | #GzipFile |
| 1072 | if not gzip: |
| 1073 | raise NotImplementedError |
| 1074 | self.io = BytesIO(response.read()) |
| 1075 | gzip.GzipFile.__init__(self, mode="rb", fileobj=self.io) |
| 1076 | |
| 1077 | def close(self): |
| 1078 | try: |
| 1079 | gzip.GzipFile.close(self) |
| 1080 | finally: |
| 1081 | self.io.close() |
| 1082 | |
| 1083 | |
| 1084 | # -------------------------------------------------------------------- |
no outgoing calls
no test coverage detected
searching dependent graphs…