コード例 #1
0
 def decode_content(self):
     content_encoding = self.content_encoding or 'identity'
     if content_encoding == 'identity':
         return
     if content_encoding != 'gzip':
         raise ValueError(
             "I don't know how to decode the content %s" % content_encoding)
     from gzip import GzipFile
     f = StringIO(self.body)
     gzip_f = GzipFile(filename='', mode='r', fileobj=f)
     self.body = gzip_f.read()
     self.content_encoding = None
     gzip_f.close()
     f.close()
コード例 #2
0
 def decode_content(self):
     content_encoding = self.content_encoding or 'identity'
     if content_encoding == 'identity':
         return
     if content_encoding != 'gzip':
         raise ValueError("I don't know how to decode the content %s" %
                          content_encoding)
     from gzip import GzipFile
     f = StringIO(self.body)
     gzip_f = GzipFile(filename='', mode='r', fileobj=f)
     self.body = gzip_f.read()
     self.content_encoding = None
     gzip_f.close()
     f.close()
コード例 #3
0
ファイル: response.py プロジェクト: startup-one/cogofly
 def decode_content(self):
     content_encoding = self.content_encoding or 'identity'
     if content_encoding == 'identity':
         return
     if content_encoding not in ('gzip', 'deflate'):
         raise ValueError("I don't know how to decode the content %s" %
                          content_encoding)
     if content_encoding == 'gzip':
         from gzip import GzipFile
         f = StringIO(self.body)
         gzip_f = GzipFile(filename='', mode='r', fileobj=f)
         self.body = gzip_f.read()
         self.content_encoding = None
         gzip_f.close()
         f.close()
     else:
         # Weird feature: http://bugs.python.org/issue5784
         self.body = zlib.decompress(self.body, -15)
         self.content_encoding = None
コード例 #4
0
ファイル: response.py プロジェクト: 404minds/quiz-forest
 def decode_content(self):
     content_encoding = self.content_encoding or 'identity'
     if content_encoding == 'identity':
         return
     if content_encoding not in ('gzip', 'deflate'):
         raise ValueError(
             "I don't know how to decode the content %s" % content_encoding)
     if content_encoding == 'gzip':
         from gzip import GzipFile
         f = StringIO(self.body)
         gzip_f = GzipFile(filename='', mode='r', fileobj=f)
         self.body = gzip_f.read()
         self.content_encoding = None
         gzip_f.close()
         f.close()
     else:
         # Weird feature: http://bugs.python.org/issue5784
         self.body = zlib.decompress(self.body, -15)
         self.content_encoding = None