accept variants of returned json mime type (#33894)
This commit is contained in:
parent
ddc3465408
commit
ff4eb94a04
1 changed files with 3 additions and 1 deletions
|
@ -236,6 +236,8 @@ import ansible.module_utils.six as six
|
|||
from ansible.module_utils._text import to_native, to_text
|
||||
from ansible.module_utils.urls import fetch_url, url_argument_spec
|
||||
|
||||
JSON_CANDIDATES = ('text', 'json', 'javascript')
|
||||
|
||||
|
||||
def write_file(module, url, dest, content):
|
||||
# create a tempfile with some test content
|
||||
|
@ -475,7 +477,7 @@ def main():
|
|||
if 'charset' in params:
|
||||
content_encoding = params['charset']
|
||||
u_content = to_text(content, encoding=content_encoding)
|
||||
if 'application/json' in content_type or 'text/json' in content_type:
|
||||
if any(candidate in content_type for candidate in JSON_CANDIDATES):
|
||||
try:
|
||||
js = json.loads(u_content)
|
||||
uresp['json'] = js
|
||||
|
|
Loading…
Reference in a new issue