summaryrefslogtreecommitdiff
path: root/docs/testing.txt
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2007-02-17 00:23:09 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2007-02-17 00:23:09 +0000
commitd6d51c9546a8734683c75bddc2cab93e05247f1e (patch)
treeb20727a1b01017f67f214bc4925a7783b8535f40 /docs/testing.txt
parent4a85a75fb0e3185dc77362c16e80219dac168c05 (diff)
Fixed #3160 -- Added the ability to control the content type in a test client POST request. This is to allow easier testing of json-rpc/xml-rpc/soap etc interfaces. Thanks to Mikeal Rogers for the suggestion, and Ben <afternoon@uk2.net> for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4529 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/testing.txt')
-rw-r--r--docs/testing.txt20
1 files changed, 13 insertions, 7 deletions
diff --git a/docs/testing.txt b/docs/testing.txt
index 6b6aecba38..33014723cd 100644
--- a/docs/testing.txt
+++ b/docs/testing.txt
@@ -217,15 +217,21 @@ can be invoked on the ``Client`` instance.
http://yoursite.com/customers/details/?name=fred&age=7
-``post(path, data={})``
- Make a POST request on the provided ``path``. The key-value pairs in the
- data dictionary will be used to create the POST data payload. This payload
- will be transmitted with the mimetype ``multipart/form-data``.
-
- However submitting files is a special case. To POST a file, you need only
+``post(path, data={}, content_type=MULTIPART_CONTENT)``
+ Make a POST request on the provided ``path``. If you provide a content type
+ (e.g., ``text/xml`` for an XML payload), the contents of ``data`` will be
+ sent as-is in the POST request, using the content type in the HTTP
+ ``Content-Type`` header.
+
+ If you do not provide a value for ``content_type``, the values in
+ ``data`` will be transmitted with a content type of ``multipart/form-data``.
+ The key-value pairs in the data dictionary will be encoded as a multipart
+ message and used to create the POST data payload.
+
+ Submitting files is a special case. To POST a file, you need only
provide the file field name as a key, and a file handle to the file you wish to
upload as a value. The Test Client will populate the two POST fields (i.e.,
- ``field`` and ``field_file``) required by FileField. For example::
+ ``field`` and ``field_file``) required by Django's FileField. For example::
c = Client()
f = open('wishlist.doc')