Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make REST client actually return headers when http method is HEAD #2763

Merged
merged 1 commit into from
Feb 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions easybuild/base/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,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