Avoid empty body failure on HEAD requests
HTTP specification states clearly that HEAD requests should have no body, so we should not fail on these. Change-Id: I9d2418f26c26b2a40f6bafaf86ed6640fbf83b0c
This commit is contained in:
parent
4150a83d45
commit
5e8dfb9065
@ -531,13 +531,14 @@ class Jenkins(object):
|
||||
response.raise_for_status()
|
||||
|
||||
headers = response.headers
|
||||
if (headers.get('content-length') is None and
|
||||
headers.get('transfer-encoding') is None and
|
||||
(response.content is None or len(response.content) <= 0)):
|
||||
# response body should only exist if one of these is provided
|
||||
raise EmptyResponseException(
|
||||
"Error communicating with server[%s]: "
|
||||
"empty response" % self.server)
|
||||
if response.request.method != 'HEAD':
|
||||
if (headers.get('content-length') is None and
|
||||
headers.get('transfer-encoding') is None and
|
||||
(response.content is None or len(response.content) <= 0)):
|
||||
# response body should only exist if one of these is provided
|
||||
raise EmptyResponseException(
|
||||
"Error communicating with server[%s]: "
|
||||
"empty response" % self.server)
|
||||
|
||||
# Response objects will automatically return unicode encoded
|
||||
# when accessing .text property
|
||||
|
Loading…
x
Reference in New Issue
Block a user