Skip to content

Commit

Permalink
move request.content_type to property, with None as default
Browse files Browse the repository at this point in the history
  • Loading branch information
dtkav committed Dec 12, 2019
1 parent fd89862 commit 171cbb3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion connexion/lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ def __init__(self,
self.json_getter = json_getter
self.files = files
self.context = context if context is not None else {}
self.content_type = self.headers.get("Content-Type", "")

@property
def content_type(self):
return self.headers.get("Content-Type")

@property
def json(self):
Expand Down
4 changes: 2 additions & 2 deletions connexion/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def is_form_mimetype(mimetype):
try:
mimetype = mimetype.split(";")[0]
maintype, subtype = mimetype.split('/') # type: str, str
except ValueError:
except (ValueError, AttributeError):
return False

multipart = maintype == 'multipart' and subtype.startswith("form-data")
Expand All @@ -133,7 +133,7 @@ def is_json_mimetype(mimetype):
"""
try:
maintype, subtype = mimetype.split('/') # type: str, str
except ValueError:
except (ValueError, AttributeError):
return False
return maintype == 'application' and (subtype == 'json' or subtype.endswith('+json'))

Expand Down

0 comments on commit 171cbb3

Please sign in to comment.