From 0985ade4dbb8a59247c34b0746a39ac01cb62743 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 18 Feb 2026 16:44:17 -0500 Subject: [PATCH] Provide optional way to request response headers Change-Id: I27d3389f601dd4684146e5cb748f6f8b65586608 --- pyghmi/util/webclient.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyghmi/util/webclient.py b/pyghmi/util/webclient.py index d863b265..ce29c82b 100644 --- a/pyghmi/util/webclient.py +++ b/pyghmi/util/webclient.py @@ -246,7 +246,7 @@ class SecureHTTPConnection(httplib.HTTPConnection, object): return {} def grab_json_response_with_status(self, url, data=None, referer=None, - headers=None, method=None): + headers=None, method=None, returnheaders=False): webclient = self.dupe() if isinstance(data, dict): data = json.dumps(data) @@ -281,7 +281,11 @@ class SecureHTTPConnection(httplib.HTTPConnection, object): body = body.decode('utf8') except Exception: body = body.decode('iso-8859-1') + if returnheaders: + return json.loads(body) if body else {}, rsp.status, dict(rsp.headers) return json.loads(body) if body else {}, rsp.status + if returnheaders: + return body, rsp.status, dict(rsp.headers) return body, rsp.status def grab_rsp(self, url, data=None, referer=None, headers=None, method=None):