Skip to content

Commit

Permalink
Merge pull request #2763 from migueldiascosta/fix_rest_headers
Browse files Browse the repository at this point in the history
make REST client actually return headers when http method is HEAD
  • Loading branch information
boegel authored Feb 13, 2019
2 parents 8c760f2 + 983651b commit 0862138
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions easybuild/base/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0862138

Please sign in to comment.