Merge branch 'trunk' into libcloud_910
diff --git a/libcloud/common/base.py b/libcloud/common/base.py
index 0d458fc..ca510e7 100644
--- a/libcloud/common/base.py
+++ b/libcloud/common/base.py
@@ -42,8 +42,6 @@
 from libcloud.utils.py3 import urlencode
 
 from libcloud.utils.misc import lowercase_keys, retry
-from libcloud.utils.compression import decompress_data
-
 from libcloud.common.exceptions import exception_from_message
 from libcloud.common.types import LibcloudError, MalformedResponseError
 from libcloud.httplib_ssl import LibcloudConnection, HttpLibResponseProxy
@@ -200,30 +198,6 @@
         return self.status in [requests.codes.ok, requests.codes.created,
                                httplib.OK, httplib.CREATED, httplib.ACCEPTED]
 
-    def _decompress_response(self, body, headers):
-        """
-        Decompress a response body if it is using deflate or gzip encoding.
-
-        :param body: Response body.
-        :type body: ``str``
-
-        :param headers: Response headers.
-        :type headers: ``dict``
-
-        :return: Decompressed response
-        :rtype: ``str``
-        """
-        encoding = headers.get('content-encoding', None)
-
-        if encoding in ['zlib', 'deflate']:
-            body = decompress_data('zlib', body)
-        elif encoding in ['gzip', 'x-gzip']:
-            body = decompress_data('gzip', body)
-        else:
-            body = body.strip()
-
-        return body
-
 
 class JsonResponse(Response):
     """
diff --git a/libcloud/test/test_logging_connection.py b/libcloud/test/test_logging_connection.py
index e7088a4..85c6547 100644
--- a/libcloud/test/test_logging_connection.py
+++ b/libcloud/test/test_logging_connection.py
@@ -15,6 +15,7 @@
 
 import sys
 from io import StringIO
+import zlib
 import requests_mock
 
 import libcloud
@@ -49,5 +50,20 @@
         self.assertIn('-i -X GET', log)
         self.assertIn('data', log)
 
+    def test_debug_log_class_handles_request_with_compression(self):
+        request = zlib.compress(b'data')
+        with StringIO() as fh:
+            libcloud.enable_debug(fh)
+            conn = Connection(url='http://test.com/')
+            conn.connect()
+            self.assertEqual(conn.connection.host, 'http://test.com')
+            with requests_mock.mock() as m:
+                m.get('http://test.com/test', content=request,
+                      headers={'content-encoding': 'zlib'})
+                conn.request('/test')
+            log = fh.getvalue()
+        self.assertTrue(isinstance(conn.connection, LoggingConnection))
+        self.assertIn('-i -X GET', log)
+
 if __name__ == '__main__':
     sys.exit(unittest.main())
diff --git a/libcloud/utils/compression.py b/libcloud/utils/compression.py
deleted file mode 100644
index 9840538..0000000
--- a/libcloud/utils/compression.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import zlib
-import gzip
-
-from libcloud.utils.py3 import PY3
-from libcloud.utils.py3 import StringIO
-
-
-__all__ = [
-    'decompress_data'
-]
-
-
-def decompress_data(compression_type, data):
-    if compression_type == 'zlib':
-        return zlib.decompress(data)
-    elif compression_type == 'gzip':
-        # TODO: Should export BytesIO as StringIO in libcloud.utils.py3
-        if PY3:
-            from io import BytesIO
-            cls = BytesIO
-        else:
-            cls = StringIO
-
-        return gzip.GzipFile(fileobj=cls(data)).read()
-    else:
-        raise Exception('Invalid or onsupported compression type: %s' %
-                        (compression_type))
diff --git a/libcloud/utils/loggingconnection.py b/libcloud/utils/loggingconnection.py
index 1e3ff41..265f645 100644
--- a/libcloud/utils/loggingconnection.py
+++ b/libcloud/utils/loggingconnection.py
@@ -30,7 +30,6 @@
 from libcloud.utils.py3 import _real_unicode as u
 
 from libcloud.utils.misc import lowercase_keys
-from libcloud.utils.compression import decompress_data
 
 
 class LoggingConnection(LibcloudConnection):
@@ -62,14 +61,8 @@
 
         headers = lowercase_keys(dict(r.getheaders()))
 
-        encoding = headers.get('content-encoding', None)
         content_type = headers.get('content-type', None)
 
-        if encoding in ['zlib', 'deflate']:
-            body = decompress_data('zlib', body)
-        elif encoding in ['gzip', 'x-gzip']:
-            body = decompress_data('gzip', body)
-
         pretty_print = os.environ.get('LIBCLOUD_DEBUG_PRETTY_PRINT_RESPONSE',
                                       False)