summaryrefslogtreecommitdiff
path: root/gitlab/__init__.py
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2019-01-19 09:13:58 +0100
committerGauvain Pocentek <gauvain@pocentek.net>2019-01-19 09:13:58 +0100
commit35a6d85acea4776e9c4ad23ff75259481a6bcf8d (patch)
tree7205ff40b422e22fb91bdb3fcf3301b3877dd46a /gitlab/__init__.py
parent89679ce5ee502e57dbe7cec2b78f4f70b85fd3a5 (diff)
downloadgitlab-fix/683/raw_download.tar.gz
fix(api): Don't try to parse raw downloadsfix/683/raw_download
http_get always tries to interpret the retrieved data if the content-type is json. In some cases (artifact download for instance) this is not the expected behavior. This patch changes http_get and download methods to always get the raw data without parsing. Closes #683
Diffstat (limited to 'gitlab/__init__.py')
-rw-r--r--gitlab/__init__.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py
index c280974..0387b0f 100644
--- a/gitlab/__init__.py
+++ b/gitlab/__init__.py
@@ -517,7 +517,8 @@ class Gitlab(object):
error_message=error_message,
response_body=result.content)
- def http_get(self, path, query_data={}, streamed=False, **kwargs):
+ def http_get(self, path, query_data={}, streamed=False, raw=False,
+ **kwargs):
"""Make a GET request to the Gitlab server.
Args:
@@ -525,6 +526,7 @@ class Gitlab(object):
'http://whatever/v4/api/projecs')
query_data (dict): Data to send as query parameters
streamed (bool): Whether the data should be streamed
+ raw (bool): If True do not try to parse the output as json
**kwargs: Extra options to send to the server (e.g. sudo)
Returns:
@@ -538,8 +540,10 @@ class Gitlab(object):
"""
result = self.http_request('get', path, query_data=query_data,
streamed=streamed, **kwargs)
- if (result.headers['Content-Type'] == 'application/json' and
- not streamed):
+
+ if (result.headers['Content-Type'] == 'application/json'
+ and not streamed
+ and not raw):
try:
return result.json()
except Exception: