From da0eec2e42fa2e0319ec446446dde55a0c3c828f Mon Sep 17 00:00:00 2001 From: Kurt Griffiths Date: Thu, 22 Sep 2016 16:28:03 -0600 Subject: [PATCH] fix(Request): Also allow PUT and PATCH parsing of x-www-form-urlencoded (#908) --- falcon/request.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/falcon/request.py b/falcon/request.py index 3c8c33a..5557fa7 100644 --- a/falcon/request.py +++ b/falcon/request.py @@ -381,10 +381,16 @@ class Request(object): # PERF(kgriffs): Technically, we should spend a few more # cycles and parse the content type for real, but # this heuristic will work virtually all the time. - if (self.options.auto_parse_form_urlencoded and - self.content_type is not None and - 'application/x-www-form-urlencoded' in self.content_type and - self.method == 'POST'): + if ( + self.options.auto_parse_form_urlencoded and + self.content_type is not None and + 'application/x-www-form-urlencoded' in self.content_type and + + # NOTE(kgriffs): POST is what we would normally expect, but + # just in case some apps like to color outside the lines, + # we'll allow PUT and PATCH to avoid breaking them. + self.method in ('POST', 'PUT', 'PATCH') + ): self._parse_form_urlencoded() if self.context_type is None: