From 203f1c1b318c9411bafe7fb4e05b7e370451a6b4 Mon Sep 17 00:00:00 2001 From: Giuseppe Date: Fri, 16 Oct 2020 13:57:45 +0200 Subject: [PATCH] get_deserialization_method with faulty content-type: try to detect if json all the way --- src/oidcrp/util.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/oidcrp/util.py b/src/oidcrp/util.py index ea6939d..fa9d17f 100755 --- a/src/oidcrp/util.py +++ b/src/oidcrp/util.py @@ -201,10 +201,14 @@ def get_deserialization_method(reqresp): logger.debug("resp.headers: %s" % (sanitize(reqresp.headers),)) logger.debug("resp.txt: %s" % (sanitize(reqresp.text),)) - try: - _ctype = reqresp.headers["content-type"] - except KeyError: - return 'urlencoded' # reasonable default ?? + _ctype = reqresp.headers.get("content-type") + if not _ctype: + # let's try to detect the format + try: + content = reqresp.json() + return 'json' + except: + return 'urlencoded' # reasonable default ?? if match_to_("application/json", _ctype) or match_to_( 'application/jrd+json', _ctype):