diff options
-rw-r--r-- | lib/ansible/module_utils/urls.py | 2 | ||||
-rw-r--r-- | lib/ansible/modules/web_infrastructure/jenkins_script.py | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/ansible/module_utils/urls.py b/lib/ansible/module_utils/urls.py index 8884fe3b93..c6323931c7 100644 --- a/lib/ansible/module_utils/urls.py +++ b/lib/ansible/module_utils/urls.py @@ -941,7 +941,7 @@ def fetch_url(module, url, data=None, headers=None, method=None, :kwarg last_mod_time: Default: None :kwarg int timeout: Default: 10 - :returns: A tuple of (**response**, **info**). Use ``response.body()`` to read the data. + :returns: A tuple of (**response**, **info**). Use ``response.read()`` to read the data. The **info** contains the 'status' and other meta data. When a HttpError (status > 400) occurred then ``info['body']`` contains the error response data:: diff --git a/lib/ansible/modules/web_infrastructure/jenkins_script.py b/lib/ansible/modules/web_infrastructure/jenkins_script.py index 85c0ba5fa8..70cea925d7 100644 --- a/lib/ansible/modules/web_infrastructure/jenkins_script.py +++ b/lib/ansible/modules/web_infrastructure/jenkins_script.py @@ -116,6 +116,7 @@ import json from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.six.moves.urllib.parse import urlencode from ansible.module_utils.urls import fetch_url +from ansible.module_utils._text import to_native def is_csrf_protection_enabled(module): @@ -125,7 +126,7 @@ def is_csrf_protection_enabled(module): if info["status"] != 200: module.fail_json(msg="HTTP error " + str(info["status"]) + " " + info["msg"]) - content = resp.read() + content = to_native(resp.read()) return json.loads(content).get('useCrumbs', False) @@ -136,7 +137,7 @@ def get_crumb(module): if info["status"] != 200: module.fail_json(msg="HTTP error " + str(info["status"]) + " " + info["msg"]) - content = resp.read() + content = to_native(resp.read()) return json.loads(content) @@ -182,7 +183,7 @@ def main(): if info["status"] != 200: module.fail_json(msg="HTTP error " + str(info["status"]) + " " + info["msg"]) - result = resp.read() + result = to_native(resp.read()) if 'Exception:' in result and 'at java.lang.Thread' in result: module.fail_json(msg="script failed with stacktrace:\n " + result) |