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

Commit

Permalink
Merge pull request #30 from IdentityPython/dev
Browse files Browse the repository at this point in the history
get_deserialization_method with faulty content-type: try to detect if json all the way
  • Loading branch information
peppelinux authored Oct 17, 2020
2 parents b46fe2d + 203f1c1 commit 54e2783
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/oidcrp/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 54e2783

Please sign in to comment.