diff options
| author | Scott Bahling <sbahling@suse.de> | 2018-08-03 16:42:16 +0200 |
|---|---|---|
| committer | Scott Bahling <sbahling@suse.de> | 2018-08-03 16:42:41 +0200 |
| commit | b15e41a14f03d66f54353a7185cc57319c16ee17 (patch) | |
| tree | 33f4bf8034060398f7248987a379da456ad32c52 /obsapi/httpapi.py | |
| parent | 494f2c4dc9c5d1937545e0af54345c4d0d578bee (diff) | |
| download | obsapi-b15e41a14f03d66f54353a7185cc57319c16ee17.tar.gz obsapi-b15e41a14f03d66f54353a7185cc57319c16ee17.tar.xz obsapi-b15e41a14f03d66f54353a7185cc57319c16ee17.zip | |
Add streaming option for HTTP get method
Diffstat (limited to 'obsapi/httpapi.py')
| -rw-r--r-- | obsapi/httpapi.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/obsapi/httpapi.py b/obsapi/httpapi.py index ea0c9fb..6a207ec 100644 --- a/obsapi/httpapi.py +++ b/obsapi/httpapi.py @@ -52,10 +52,13 @@ class ObsHttpApi(object): url = '{0}{1}{2}'.format(self.apiurl, self.rootapi, api) + stream = params.pop('stream', False) + def try_get(): r = requests.get(url, auth=self.__auth, params=params, + stream=stream, verify=self.verify_ssl) self._response = r return r @@ -112,11 +115,14 @@ class ObsHttpApi(object): def get(self, *args, **params): binary_get = params.pop('binary_get', False) api = self.__api(*args) + stream = params.get('stream', False) r = self.__api_get(api, params=params) if not self.success: - return self.default_xml + return None if binary_get: + if stream: + return r return r.content return r.text |
