summaryrefslogtreecommitdiff
path: root/docs/user
diff options
context:
space:
mode:
authorKenneth Reitz <me@kennethreitz.org>2017-05-27 17:24:06 -0400
committerKenneth Reitz <me@kennethreitz.org>2017-05-27 17:24:06 -0400
commit2e67c86075de9bba6b9d8ae0c9d7e844ef06bcb6 (patch)
tree27330b3bb10eed7b64b34cd31a3b320cf904a426 /docs/user
parentf0fb5034fc7118008c5ee88f10ce780fbcbcf181 (diff)
parent21972c4601378fcad28cbc63466775b76d6a888a (diff)
downloadpython-requests-2e67c86075de9bba6b9d8ae0c9d7e844ef06bcb6.tar.gz
merge
Diffstat (limited to 'docs/user')
-rw-r--r--docs/user/quickstart.rst41
1 files changed, 40 insertions, 1 deletions
diff --git a/docs/user/quickstart.rst b/docs/user/quickstart.rst
index 60cc73fb..156fd15d 100644
--- a/docs/user/quickstart.rst
+++ b/docs/user/quickstart.rst
@@ -234,6 +234,45 @@ dictionary of data will automatically be form-encoded when the request is made::
...
}
+You can also pass a list of tuples to the ``data`` argument. This is particularly
+useful when the form has multiple elements that use the same key::
+
+ >>> payload = (('key1', 'value1'), ('key1', 'value2'))
+ >>> r = requests.post('http://httpbin.org/post', data=payload)
+ >>> print(r.text)
+ {
+ ...
+ "form": {
+ "key1": [
+ "value1",
+ "value2"
+ ]
+ },
+ ...
+ }
+
+Value of each payload element can be a scalar or an iterable::
+
+ >>> payload = (('key1', ('value1', 1, (1, 2))), {'key2', ('value2', 2)})
+ >>> r = requests.post('http://httpbin.org/post', data=payload)
+ >>> print(r.text)
+ {
+ ...
+ "form": {
+ "key1": [
+ "value1",
+ "1",
+ "1",
+ "2"
+ ],
+ "key2": [
+ "value2",
+ "2"
+ ]
+ },
+ ...
+ }
+
There are many times that you want to send data that is not form-encoded. If
you pass in a ``string`` instead of a ``dict``, that data will be posted directly.
@@ -485,7 +524,7 @@ Timeouts
--------
You can tell Requests to stop waiting for a response after a given number of
-seconds with the ``timeout`` parameter. Nearly all production code should use
+seconds with the ``timeout`` parameter. Nearly all production code should use
this parameter in nearly all requests. Failure to do so can cause your program
to hang indefinitely::