summaryrefslogtreecommitdiff
path: root/docs/user/advanced.rst
diff options
context:
space:
mode:
authorCory Benfield <lukasaoz@gmail.com>2015-10-14 13:23:19 +0100
committerCory Benfield <lukasaoz@gmail.com>2015-10-14 13:23:19 +0100
commit7c55446b7ec0978d38fceda5ad4bc45e5b26f1f1 (patch)
tree4925f4c8cc8593e5ee053abe3b03bf7fbee2d933 /docs/user/advanced.rst
parent18a6b601100db978f3a6e191816456e75bc47e0f (diff)
downloadpython-requests-7c55446b7ec0978d38fceda5ad4bc45e5b26f1f1.tar.gz
Add warnings about text/binary mode files.
Diffstat (limited to 'docs/user/advanced.rst')
-rw-r--r--docs/user/advanced.rst20
1 files changed, 19 insertions, 1 deletions
diff --git a/docs/user/advanced.rst b/docs/user/advanced.rst
index 175fc9b7..62959a93 100644
--- a/docs/user/advanced.rst
+++ b/docs/user/advanced.rst
@@ -315,6 +315,15 @@ file-like object for your body::
with open('massive-body', 'rb') as f:
requests.post('http://some.url/streamed', data=f)
+.. warning:: It is strongly recommended that you open files in `binary mode`_.
+ This is because Requests may attempt to provide the
+ ``Content-Length`` header for you, and if it does this value will
+ be set to the number of *bytes* in the file. Errors may occur if
+ you open the file in *text mode*.
+
+.. _binary mode: https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files
+
+
.. _chunk-encoding:
Chunk-Encoded Requests
@@ -362,6 +371,15 @@ To do that, just set files to a list of tuples of (form_field_name, file_info):
...
}
+.. warning:: It is strongly recommended that you open files in `binary mode`_.
+ This is because Requests may attempt to provide the
+ ``Content-Length`` header for you, and if it does this value will
+ be set to the number of *bytes* in the file. Errors may occur if
+ you open the file in *text mode*.
+
+.. _binary mode: https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files
+
+
.. _event-hooks:
Event Hooks
@@ -519,7 +537,7 @@ any request to the given scheme and exact hostname.
}
Note that proxy URLs must include the scheme.
-
+
.. _compliance:
Compliance