Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep blank values on POST and PUT requests #109

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions brubeck/request.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import cgi
import json
import Cookie
import logging
Expand Down Expand Up @@ -43,7 +42,7 @@ def __init__(self, sender, conn_id, path, headers, body, url, *args, **kwargs):
self.arguments = {}
if 'QUERY' in self.headers:
query = self.headers['QUERY']
arguments = cgi.parse_qs(query.encode("utf-8"))
arguments = urlparse.parse_qs(query.encode("utf-8"))
for name, values in arguments.iteritems():
values = [v for v in values if v]
if values:
Expand All @@ -53,11 +52,8 @@ def __init__(self, sender, conn_id, path, headers, body, url, *args, **kwargs):
if self.method in ("POST", "PUT") and self.content_type:
form_encoding = "application/x-www-form-urlencoded"
if self.content_type.startswith(form_encoding):
arguments = cgi.parse_qs(self.body)
for name, values in arguments.iteritems():
values = [v for v in values if v]
if values:
self.arguments.setdefault(name, []).extend(values)
arguments = urlparse.parse_qs(self.body, keep_blank_values=True)
self.arguments.update(arguments)
# Not ready for this, but soon
elif self.content_type.startswith("multipart/form-data"):
fields = self.content_type.split(";")
Expand Down