X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/b2711d07638204cb78be7e7a54e265d816ae31ac..5274191c1e165a615645a4c10c8ca0220d347a3b:/third_party/transifex-client/txclib/http_utils.py diff --git a/third_party/transifex-client/txclib/http_utils.py b/third_party/transifex-client/txclib/http_utils.py deleted file mode 100644 index 3243149c..00000000 --- a/third_party/transifex-client/txclib/http_utils.py +++ /dev/null @@ -1,46 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -HTTP-related utility functions. -""" - -from __future__ import with_statement -import gzip -try: - import cStringIO as StringIO -except ImportError: - import StringIO - - -def _gzip_decode(gzip_data): - """ - Unzip gzipped data and return them. - - :param gzip_data: Gzipped data. - :returns: The actual data. - """ - try: - gzip_data = StringIO.StringIO(gzip_data) - gzip_file = gzip.GzipFile(fileobj=gzip_data) - data = gzip_file.read() - return data - finally: - gzip_data.close() - - -def http_response(response): - """ - Return the response of a HTTP request. - - If the response has been gzipped, gunzip it first. - - :param response: The raw response of a HTTP request. - :returns: A response suitable to be used by clients. - """ - metadata = response.info() - data = response.read() - response.close() - if metadata.get('content-encoding') == 'gzip': - return _gzip_decode(data) - else: - return data