mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Handle fetch_url error gracefully (#23821)
Fix adds http response code check for fetch_url. Also, method in fetch_url call. Fixes https://github.com/ansible/ansible/issues/23800 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
d02a9016a2
commit
86a63cfcd7
1 changed files with 4 additions and 1 deletions
|
@ -722,7 +722,10 @@ def download(module, deb):
|
|||
BUFSIZE = 65536
|
||||
|
||||
try:
|
||||
rsp, info = fetch_url(module, deb)
|
||||
rsp, info = fetch_url(module, deb, method='GET')
|
||||
if info['status'] != 200:
|
||||
module.fail_json(msg="Failed to download %s, %s" % (deb,
|
||||
info['msg']))
|
||||
# Ensure file is open in binary mode for Python 3
|
||||
f = open(package, 'wb')
|
||||
# Read 1kb at a time to save on ram
|
||||
|
|
Loading…
Reference in a new issue