Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 54e2783

Browse files
authored
Merge pull request #30 from IdentityPython/dev
get_deserialization_method with faulty content-type: try to detect if json all the way
2 parents b46fe2d + 203f1c1 commit 54e2783

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/oidcrp/util.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,14 @@ def get_deserialization_method(reqresp):
201201
logger.debug("resp.headers: %s" % (sanitize(reqresp.headers),))
202202
logger.debug("resp.txt: %s" % (sanitize(reqresp.text),))
203203

204-
try:
205-
_ctype = reqresp.headers["content-type"]
206-
except KeyError:
207-
return 'urlencoded' # reasonable default ??
204+
_ctype = reqresp.headers.get("content-type")
205+
if not _ctype:
206+
# let's try to detect the format
207+
try:
208+
content = reqresp.json()
209+
return 'json'
210+
except:
211+
return 'urlencoded' # reasonable default ??
208212

209213
if match_to_("application/json", _ctype) or match_to_(
210214
'application/jrd+json', _ctype):

0 commit comments

Comments
 (0)