diff --git a/AUTHORS.rst b/AUTHORS.rst index d434489..eeb2d61 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -10,3 +10,4 @@ Patches and Suggestions - Darlene Wong - Michael Richardson - Garfield Freeman +- Justin Bradfield diff --git a/lib/pan/xapi.py b/lib/pan/xapi.py index 0e21b72..4ed8cf4 100644 --- a/lib/pan/xapi.py +++ b/lib/pan/xapi.py @@ -201,7 +201,7 @@ def __get_header(self, response, name): return types def __set_response(self, response): - message_body = response.read() + message_body = response.pan_body content_type = self.__get_header(response, 'content-type') if not content_type: @@ -515,7 +515,8 @@ def __api_request(self, query): kwargs['timeout'] = self.timeout try: - response = urlopen(**kwargs) + with urlopen(**kwargs) as response: + response.pan_body = response.read() # XXX handle httplib.BadStatusLine when http to port 443 except ssl.CertificateError as e: @@ -534,6 +535,7 @@ def __api_request(self, query): self._log(DEBUG2, 'HTTP response headers:') self._log(DEBUG2, '%s', response.info()) + self._log(DEBUG2, 'stream closed %s', response.closed) return response