Skip to content
Myr

merge

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parents f0fb503, 21972c4 · Browse files · 2 files+41 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+41 added−1 removed

  • other:+41 added−1 removed

2 files+41 added−1 removed

modified:docs/user/quickstart.rst+40 added-1 removed
232 unmodified lines
233 },234 ...235 }236237You can also pass a list of tuples to the ``data`` argument. This is particularly238useful when the form has multiple elements that use the same key::239240 >>> payload = (('key1', 'value1'), ('key1', 'value2'))241 >>> r = requests.post('http://httpbin.org/post', data=payload)242 >>> print(r.text)243 {244 ...245 "form": {246 "key1": [247 "value1",248 "value2"249 ]250 },251 ...252 }253254Value of each payload element can be a scalar or an iterable::255256 >>> payload = (('key1', ('value1', 1, (1, 2))), {'key2', ('value2', 2)})257 >>> r = requests.post('http://httpbin.org/post', data=payload)258 >>> print(r.text)259 {260 ...261 "form": {262 "key1": [263 "value1",264 "1",265 "1",266 "2"267 ],268 "key2": [269 "value2",270 "2"271 ]272 },273 ...274 }275276There are many times that you want to send data that is not form-encoded. If277you pass in a ``string`` instead of a ``dict``, that data will be posted directly.278279For example, the GitHub API v3 accepts JSON-Encoded POST/PATCH data::
243 unmodified lines
523Timeouts524--------525526You can tell Requests to stop waiting for a response after a given number of488seconds with the ``timeout`` parameter. Nearly all production code should use 527seconds with the ``timeout`` parameter. Nearly all production code should use528this parameter in nearly all requests. Failure to do so can cause your program529to hang indefinitely::530531 >>> requests.get('http://github.com', timeout=0.001)
36 unmodified lines
modified:AUTHORS.rst+1 added
179 unmodified lines
180- Matt Kohl (`@mattkohl <https://github.com/mattkohl>`_)181- Jonathan Vanasco (`@jvanasco <https://github.com/jvanasco>`_)182- David Fontenot (`@davidfontenot <https://github.com/davidfontenot>`_)183- Shmuel Amar (`@shmuelamar <https://github.com/shmuelamar>`_)184- Gary Wu (`@garywu <https://github.com/garywu>`_)