diff --git a/easybuild/base/rest.py b/easybuild/base/rest.py index 24cac57e26..46c0379b1f 100644 --- a/easybuild/base/rest.py +++ b/easybuild/base/rest.py @@ -169,11 +169,14 @@ def request(self, method, url, body, headers, content_type=None): # TODO: in recent python: Context manager conn = self.get_connection(method, url, body, headers) status = conn.code - body = conn.read() - try: - pybody = json.loads(body) - except ValueError: - pybody = body + if method == self.HEAD: + pybody = conn.headers + else: + body = conn.read() + try: + pybody = json.loads(body) + except ValueError: + pybody = body fancylogger.getLogger().debug('reponse len: %s ', len(pybody)) conn.close() return status, pybody