Account for no POST data

The serving.request doesn't include a raw_body when the POST data
is blank, so set it to an empty dict.

Also fixed a bug where we assumed that if data wasn't a list, it
was a dict, which bombs because null POSTS result in None.
This commit is contained in:
Steve Hajducko 2015-11-09 14:53:37 -08:00 committed by rallytime
parent f40c617bad
commit 092f441cad

View file

@ -608,7 +608,7 @@ def lowdata_fmt():
# if the data was sent as urlencoded, we need to make it a list.
# this is a very forgiving implementation as different clients set different
# headers for form encoded data (including charset or something similar)
if not isinstance(data, list):
if data and not isinstance(data, list):
# Make the 'arg' param a list if not already
if 'arg' in data and not isinstance(data['arg'], list):
data['arg'] = [data['arg']]
@ -2132,7 +2132,9 @@ class Webhook(object):
'''
tag = '/'.join(itertools.chain(self.tag_base, args))
data = cherrypy.serving.request.unserialized_data
raw_body = cherrypy.serving.request.raw_body
if not data:
data = {}
raw_body = getattr(cherrypy.serving.request, 'raw_body', '')
headers = dict(cherrypy.request.headers)
ret = self.event.fire_event({