This commit is contained in:
Andres Riancho 2013-12-27 12:26:25 -03:00 committed by Steve Pulec
parent 5f7e60194f
commit d58f406de4

View File

@ -9,18 +9,30 @@ from moto.core.utils import camelcase_to_underscores, method_names_from_class
class BaseResponse(object): class BaseResponse(object):
def dispatch(self, request, full_url, headers): def dispatch(self, request, full_url, headers):
querystring = None
if hasattr(request, 'body'): if hasattr(request, 'body'):
# Boto # Boto
self.body = request.body self.body = request.body
else: else:
# Flask server # Flask server
# FIXME: At least in Flask==0.10.1, request.data is an empty string
# and the information we want is in request.form. Keeping self.body
# definition for back-compatibility
self.body = request.data self.body = request.data
querystring = parse_qs(urlparse(full_url).query) querystring = {}
if not querystring: for key, value in request.form.iteritems():
querystring = parse_qs(self.body) querystring[key] = [value,]
if not querystring:
querystring = headers
if querystring is None:
querystring = parse_qs(urlparse(full_url).query)
if not querystring:
querystring = parse_qs(self.body)
if not querystring:
querystring = headers
self.uri = full_url self.uri = full_url
self.path = urlparse(full_url).path self.path = urlparse(full_url).path