summaryrefslogtreecommitdiffstats
path: root/lib/ansible/modules/uri.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ansible/modules/uri.py')
-rw-r--r--lib/ansible/modules/uri.py28
1 files changed, 13 insertions, 15 deletions
diff --git a/lib/ansible/modules/uri.py b/lib/ansible/modules/uri.py
index 0aac978..7c2e924 100644
--- a/lib/ansible/modules/uri.py
+++ b/lib/ansible/modules/uri.py
@@ -3,8 +3,7 @@
# Copyright: (c) 2013, Romeo Theriault <romeot () hawaii.edu>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = r'''
@@ -108,14 +107,15 @@ options:
default: no
follow_redirects:
description:
- - Whether or not the URI module should follow redirects. V(all) will follow all redirects.
- V(safe) will follow only "safe" redirects, where "safe" means that the client is only
- doing a GET or HEAD on the URI to which it is being redirected. V(none) will not follow
- any redirects. Note that V(true) and V(false) choices are accepted for backwards compatibility,
- where V(true) is the equivalent of V(all) and V(false) is the equivalent of V(safe). V(true) and V(false)
- are deprecated and will be removed in some future version of Ansible.
+ - Whether or not the URI module should follow redirects.
+ choices:
+ all: Will follow all redirects.
+ none: Will not follow any redirects.
+ safe: Only redirects doing GET or HEAD requests will be followed.
+ urllib2: Defer to urllib2 behavior (As of writing this follows HTTP redirects).
+ 'no': (DEPRECATED, will be removed in the future version) alias of V(none).
+ 'yes': (DEPRECATED, will be removed in the future version) alias of V(all).
type: str
- choices: ['all', 'no', 'none', 'safe', 'urllib2', 'yes']
default: safe
creates:
description:
@@ -444,11 +444,10 @@ import json
import os
import re
import shutil
-import sys
import tempfile
from ansible.module_utils.basic import AnsibleModule, sanitize_keys
-from ansible.module_utils.six import PY2, PY3, binary_type, iteritems, string_types
+from ansible.module_utils.six import binary_type, iteritems, string_types
from ansible.module_utils.six.moves.urllib.parse import urlencode, urlsplit
from ansible.module_utils.common.text.converters import to_native, to_text
from ansible.module_utils.compat.datetime import utcnow, utcfromtimestamp
@@ -586,7 +585,7 @@ def uri(module, url, dest, body, body_format, method, headers, socket_timeout, c
method=method, timeout=socket_timeout, unix_socket=module.params['unix_socket'],
ca_path=ca_path, unredirected_headers=unredirected_headers,
use_proxy=module.params['use_proxy'], decompress=decompress,
- ciphers=ciphers, use_netrc=use_netrc, **kwargs)
+ ciphers=ciphers, use_netrc=use_netrc, force=module.params['force'], **kwargs)
if src:
# Try to close the open file handle
@@ -720,7 +719,7 @@ def main():
if maybe_output:
try:
- if PY3 and (r.fp is None or r.closed):
+ if r.fp is None or r.closed:
raise TypeError
content = r.read()
except (AttributeError, TypeError):
@@ -771,8 +770,7 @@ def main():
js = json.loads(u_content)
uresp['json'] = js
except Exception:
- if PY2:
- sys.exc_clear() # Avoid false positive traceback in fail_json() on Python 2
+ ...
else:
u_content = None