uri: Handle HTTP exception raised

* Handle HTTP exceptions raised when reading the content
  such as IncompleteRead

Fixes: #83794

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/84015/head
Abhijeet Kasurde 2 months ago
parent 3d40db1ac0
commit 6c193989b5

@ -0,0 +1,3 @@
---
bugfixes:
- uri - Handle HTTP exceptions raised while reading the content (https://github.com/ansible/ansible/issues/83794).

@ -732,6 +732,8 @@ def main():
# there was no content, but the error read()
# may have been stored in the info as 'body'
content = info.pop('body', b'')
except http.client.HTTPException as http_err:
module.fail_json(msg=f"HTTP Error while fetching {url}: {to_native(http_err)}")
elif r:
content = r
else:

Loading…
Cancel
Save