[stable-2.15] URI Module find json sub type (#80745) (#80891)

* uri: fixed search for json types to include strings in the format xxx/yyy+json
(cherry picked from commit 0c7361d9ac)

Co-authored-by: Brent Barbachem <barbacbd@dukes.jmu.edu>
pull/81000/head
Matt Martz 2 years ago committed by GitHub
parent 01000c622f
commit 8fe49b6b35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- uri - fix search for JSON type to include complex strings containing '+'

@ -707,7 +707,15 @@ def main():
sub_type = 'octet-stream'
content_encoding = 'utf-8'
maybe_json = content_type and sub_type.lower() in JSON_CANDIDATES
if sub_type and '+' in sub_type:
# https://www.rfc-editor.org/rfc/rfc6839#section-3.1
sub_type_suffix = sub_type.partition('+')[2]
maybe_json = content_type and sub_type_suffix.lower() in JSON_CANDIDATES
elif sub_type:
maybe_json = content_type and sub_type.lower() in JSON_CANDIDATES
else:
maybe_json = False
maybe_output = maybe_json or return_content or info['status'] not in status_code
if maybe_output:

@ -696,6 +696,18 @@
that:
- result.json.json[0] == 'JSON Test Pattern pass1'
- name: Test find JSON as subtype
uri:
url: "https://{{ httpbin_host }}/response-headers?content-type=application/ld%2Bjson"
method: POST
return_content: true
register: result
- name: Validate JSON as subtype
assert:
that:
- result.json is defined
- name: Make request that includes password in JSON keys
uri:
url: "https://{{ httpbin_host}}/get?key-password=value-password"

Loading…
Cancel
Save