]> jfr.im git - z_archive/twitter.git/commitdiff
Merge branch 'master' of git://github.com/jameslafa/twitter
authorMike Verdone <redacted>
Tue, 31 Jul 2012 18:42:48 +0000 (20:42 +0200)
committerMike Verdone <redacted>
Tue, 31 Jul 2012 18:42:48 +0000 (20:42 +0200)
Conflicts:
twitter/api.py

1  2 
twitter/api.py

diff --cc twitter/api.py
index ca191e6295fdbccfcd8d5a924bf14766b32eef3b,6b2b0bb5c79c93c05c2fe66c356a0bf574686592..8ed3ad8090c8d3a8cb362c1db67ea6ac31b4e53b
@@@ -169,10 -175,16 +175,18 @@@ class TwitterCall(object)
      def _handle_response(self, req, uri, arg_data):
          try:
              handle = urllib_request.urlopen(req)
 -            if handle.info().get('Content-Encoding') == 'gzip':
 +            if handle.headers['Content-Type'] in ['image/jpeg', 'image/png']:
 +                return handle
++            elif handle.info().get('Content-Encoding') == 'gzip':
+                 # Handle gzip decompression
+                 buf = StringIO(handle.read())
+                 f = gzip.GzipFile(fileobj=buf)
+                 data = f.read()
+             else:
+                 data = handle.read()
              if "json" == self.format:
-                 res = json.loads(handle.read().decode('utf8'))
+                 res = json.loads(data.decode('utf8'))
                  return wrap_response(res, handle.headers)
              else:
                  return wrap_response(