Don't pass follow_redirects to fetch_url, use module.params instead
This commit is contained in:
parent
22caa104e4
commit
3c59eedb9b
1 changed files with 8 additions and 1 deletions
|
@ -298,12 +298,16 @@ def uri(module, url, dest, body, body_format, method, headers, socket_timeout):
|
||||||
redir_info = {}
|
redir_info = {}
|
||||||
r = {}
|
r = {}
|
||||||
if dest is not None:
|
if dest is not None:
|
||||||
|
# Stash follow_redirects, in this block we don't want to follow
|
||||||
|
# we'll reset back to the supplied value soon
|
||||||
|
follow_redirects = module.params['follow_redirects']
|
||||||
|
module.params['follow_redirects'] = False
|
||||||
dest = os.path.expanduser(dest)
|
dest = os.path.expanduser(dest)
|
||||||
if os.path.isdir(dest):
|
if os.path.isdir(dest):
|
||||||
# first check if we are redirected to a file download
|
# first check if we are redirected to a file download
|
||||||
_, redir_info = fetch_url(module, url, data=body,
|
_, redir_info = fetch_url(module, url, data=body,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
method=method, follow_redirects=None,
|
method=method,
|
||||||
timeout=socket_timeout)
|
timeout=socket_timeout)
|
||||||
# if we are redirected, update the url with the location header,
|
# if we are redirected, update the url with the location header,
|
||||||
# and update dest with the new url filename
|
# and update dest with the new url filename
|
||||||
|
@ -317,6 +321,9 @@ def uri(module, url, dest, body, body_format, method, headers, socket_timeout):
|
||||||
tstamp = t.strftime('%a, %d %b %Y %H:%M:%S +0000')
|
tstamp = t.strftime('%a, %d %b %Y %H:%M:%S +0000')
|
||||||
headers['If-Modified-Since'] = tstamp
|
headers['If-Modified-Since'] = tstamp
|
||||||
|
|
||||||
|
# Reset follow_redirects back to the stashed value
|
||||||
|
module.params['follow_redirects'] = follow_redirects
|
||||||
|
|
||||||
resp, info = fetch_url(module, url, data=body, headers=headers,
|
resp, info = fetch_url(module, url, data=body, headers=headers,
|
||||||
method=method, timeout=socket_timeout)
|
method=method, timeout=socket_timeout)
|
||||||
r['redirected'] = redirected or info['url'] != url
|
r['redirected'] = redirected or info['url'] != url
|
||||||
|
|
Loading…
Reference in a new issue