Skip to content

Commit

Permalink
Merge pull request momosecurity#74 from flyer5200/hotfix/precise_matc…
Browse files Browse the repository at this point in the history
…h_mimetype

added content-type header non-empty judgment
  • Loading branch information
Flynnon authored May 11, 2021
2 parents b73f7e0 + f25c977 commit 5ef9766
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions risk_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
def __parse_post_body(environ, ignore_get=False):
post_data = {}

mimetype, options = cgi.parse_header(environ["CONTENT_TYPE"])
# accept post json
if mimetype == "application/json" and environ["REQUEST_METHOD"] == "POST":
storage = environ['wsgi.input'].read()
if storage:
return json.loads(storage)
content_type = environ["CONTENT_TYPE"] if "CONTENT_TYPE" in environ else None
if content_type is not None:
mimetype, options = cgi.parse_header(content_type)
# accept post json
if mimetype == "application/json" and environ["REQUEST_METHOD"] == "POST":
storage = environ['wsgi.input'].read()
if storage:
return json.loads(storage)

storage = FieldStorage(environ['wsgi.input'], environ=environ, keep_blank_values=True)

Expand Down

0 comments on commit 5ef9766

Please sign in to comment.