mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #9351 -- Modified the test client to pass on URL encoded parameters to the underlying views. Thanks to sime for the suggestion.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9398 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import urllib
|
||||
from urlparse import urlparse, urlunparse
|
||||
import sys
|
||||
import os
|
||||
try:
|
||||
@@ -260,10 +261,11 @@ class Client(object):
|
||||
"""
|
||||
Requests a response from the server using GET.
|
||||
"""
|
||||
parsed = urlparse(path)
|
||||
r = {
|
||||
'CONTENT_TYPE': 'text/html; charset=utf-8',
|
||||
'PATH_INFO': urllib.unquote(path),
|
||||
'QUERY_STRING': urlencode(data, doseq=True),
|
||||
'PATH_INFO': urllib.unquote(parsed.path),
|
||||
'QUERY_STRING': urlencode(data, doseq=True) or parsed.query,
|
||||
'REQUEST_METHOD': 'GET',
|
||||
'wsgi.input': FakePayload('')
|
||||
}
|
||||
@@ -280,10 +282,12 @@ class Client(object):
|
||||
else:
|
||||
post_data = data
|
||||
|
||||
parsed = urlparse(path)
|
||||
r = {
|
||||
'CONTENT_LENGTH': len(post_data),
|
||||
'CONTENT_TYPE': content_type,
|
||||
'PATH_INFO': urllib.unquote(path),
|
||||
'PATH_INFO': urllib.unquote(parsed.path),
|
||||
'QUERY_STRING': parsed.query,
|
||||
'REQUEST_METHOD': 'POST',
|
||||
'wsgi.input': FakePayload(post_data),
|
||||
}
|
||||
@@ -295,10 +299,11 @@ class Client(object):
|
||||
"""
|
||||
Request a response from the server using HEAD.
|
||||
"""
|
||||
parsed = urlparse(path)
|
||||
r = {
|
||||
'CONTENT_TYPE': 'text/html; charset=utf-8',
|
||||
'PATH_INFO': urllib.unquote(path),
|
||||
'QUERY_STRING': urlencode(data, doseq=True),
|
||||
'PATH_INFO': urllib.unquote(parsed.path),
|
||||
'QUERY_STRING': urlencode(data, doseq=True) or parsed.query,
|
||||
'REQUEST_METHOD': 'HEAD',
|
||||
'wsgi.input': FakePayload('')
|
||||
}
|
||||
@@ -310,9 +315,10 @@ class Client(object):
|
||||
"""
|
||||
Request a response from the server using OPTIONS.
|
||||
"""
|
||||
parsed = urlparse(path)
|
||||
r = {
|
||||
'PATH_INFO': urllib.unquote(path),
|
||||
'QUERY_STRING': urlencode(data, doseq=True),
|
||||
'PATH_INFO': urllib.unquote(parsed.path),
|
||||
'QUERY_STRING': urlencode(data, doseq=True) or parsed.query,
|
||||
'REQUEST_METHOD': 'OPTIONS',
|
||||
'wsgi.input': FakePayload('')
|
||||
}
|
||||
@@ -328,11 +334,13 @@ class Client(object):
|
||||
post_data = encode_multipart(BOUNDARY, data)
|
||||
else:
|
||||
post_data = data
|
||||
|
||||
parsed = urlparse(path)
|
||||
r = {
|
||||
'CONTENT_LENGTH': len(post_data),
|
||||
'CONTENT_TYPE': content_type,
|
||||
'PATH_INFO': urllib.unquote(path),
|
||||
'QUERY_STRING': urlencode(data, doseq=True),
|
||||
'PATH_INFO': urllib.unquote(parsed.path),
|
||||
'QUERY_STRING': urlencode(data, doseq=True) or parsed.query,
|
||||
'REQUEST_METHOD': 'PUT',
|
||||
'wsgi.input': FakePayload(post_data),
|
||||
}
|
||||
@@ -344,9 +352,10 @@ class Client(object):
|
||||
"""
|
||||
Send a DELETE request to the server.
|
||||
"""
|
||||
parsed = urlparse(path)
|
||||
r = {
|
||||
'PATH_INFO': urllib.unquote(path),
|
||||
'QUERY_STRING': urlencode(data, doseq=True),
|
||||
'PATH_INFO': urllib.unquote(parsed.path),
|
||||
'QUERY_STRING': urlencode(data, doseq=True) or parsed.query,
|
||||
'REQUEST_METHOD': 'DELETE',
|
||||
'wsgi.input': FakePayload('')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user