From d58f406de4c5adcf482ba0ee1e4a91a3b02ed3dc Mon Sep 17 00:00:00 2001 From: Andres Riancho Date: Fri, 27 Dec 2013 12:26:25 -0300 Subject: [PATCH] Fixes https://github.com/spulec/moto/issues/74 --- moto/core/responses.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/moto/core/responses.py b/moto/core/responses.py index 3d8fa138c..cef0dad5c 100644 --- a/moto/core/responses.py +++ b/moto/core/responses.py @@ -9,18 +9,30 @@ from moto.core.utils import camelcase_to_underscores, method_names_from_class class BaseResponse(object): def dispatch(self, request, full_url, headers): + querystring = None + if hasattr(request, 'body'): # Boto self.body = request.body else: # 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 - querystring = parse_qs(urlparse(full_url).query) - if not querystring: - querystring = parse_qs(self.body) - if not querystring: - querystring = headers + querystring = {} + for key, value in request.form.iteritems(): + querystring[key] = [value,] + + + 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.path = urlparse(full_url).path