mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #11371: Made django.test.Client.put() work for non-form-data PUT (i.e. JSON, etc.). Thanks, phyfus.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11656 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -362,12 +362,18 @@ class Client(object):
|
||||
else:
|
||||
post_data = data
|
||||
|
||||
# Make `data` into a querystring only if it's not already a string. If
|
||||
# it is a string, we'll assume that the caller has already encoded it.
|
||||
query_string = None
|
||||
if not isinstance(data, basestring):
|
||||
query_string = urlencode(data, doseq=True)
|
||||
|
||||
parsed = urlparse(path)
|
||||
r = {
|
||||
'CONTENT_LENGTH': len(post_data),
|
||||
'CONTENT_TYPE': content_type,
|
||||
'PATH_INFO': urllib.unquote(parsed[2]),
|
||||
'QUERY_STRING': urlencode(data, doseq=True) or parsed[4],
|
||||
'QUERY_STRING': query_string or parsed[4],
|
||||
'REQUEST_METHOD': 'PUT',
|
||||
'wsgi.input': FakePayload(post_data),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user