diff --git a/lib/pan/xapi.py b/lib/pan/xapi.py index 1318f98..d76fddd 100644 --- a/lib/pan/xapi.py +++ b/lib/pan/xapi.py @@ -242,7 +242,7 @@ def __get_header(self, response, name): return types def __set_response(self, response): - message_body = response.read() + message_body = response.body content_type = self.__get_header(response, 'content-type') if not content_type: @@ -542,7 +542,11 @@ def __api_request(self, query): kwargs['timeout'] = self.timeout try: - response = urlopen(**kwargs) + response = None + with urlopen(**kwargs) as r: + response = r + response.body = r.read() + # XXX handle httplib.BadStatusLine when http to port 443 except self._certificateerror as e: