...
|
...
|
@@ -42,13 +42,12 @@ def check_http_status(url, content_type, params, headers = {}): |
|
|
r = requests.get(url, headers = headers)
|
|
|
# check http status code
|
|
|
ret['http_code'] = r.status_code
|
|
|
#ret['message'] = r.text
|
|
|
if r.status_code == requests.codes.ok:
|
|
|
# check json response
|
|
|
# json code
|
|
|
ret["code"] = r.json()['code']
|
|
|
ret['message'] = "SUCCESS"
|
|
|
else:
|
|
|
ret["code"] = -1
|
|
|
ret['message'] = r.text
|
|
|
ret["code"] = r.status_code
|
|
|
return ret
|
|
|
|
|
|
|
...
|
...
|
@@ -94,7 +93,7 @@ def run_module(): |
|
|
# check result
|
|
|
ret = check_http_status(url, content_type, params)
|
|
|
if ret['code'] != 200:
|
|
|
module.fail_json(msg='Check Failed: http res:%i, body %s' % (ret['http_code'], ret['message']), **result)
|
|
|
module.fail_json(msg='Check Failed: http code:%i, json code: %i' % (ret['http_code'], ret['code']), **result)
|
|
|
result['response'] = ret
|
|
|
module.exit_json(**result)
|
|
|
|
...
|
...
|
|