summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorCory Benfield <lukasaoz@gmail.com>2016-09-05 17:05:09 +0100
committerCory Benfield <lukasaoz@gmail.com>2016-09-05 17:05:09 +0100
commite5fb9777b71b2f141b903236d233a5592e620f14 (patch)
treee60501083391630052f6e26172e2ca4e857672fc /docs
parent4a68c533b79c4e3ddec8e451b1091d4000c5b69f (diff)
parent41259f3ae6bbf0c2fc1ff87a1b2c403d80057a06 (diff)
downloadurllib3-e5fb9777b71b2f141b903236d233a5592e620f14.tar.gz
Merge branch 'close' of https://github.com/scop/urllib3 into scop-close
Diffstat (limited to 'docs')
-rw-r--r--docs/user-guide.rst6
1 files changed, 4 insertions, 2 deletions
diff --git a/docs/user-guide.rst b/docs/user-guide.rst
index ec74bb1c..b37343aa 100644
--- a/docs/user-guide.rst
+++ b/docs/user-guide.rst
@@ -162,7 +162,8 @@ For uploading files using ``multipart/form-data`` encoding you can use the same
approach as :ref:`form_data` and specify the file field as a tuple of
``(file_name, file_data)``::
- >>> file_data = open('example.txt').read()
+ >>> with open('example.txt') as fp:
+ ... file_data = fp.read()
>>> r = http.request(
... 'POST',
... 'http://httpbin.org/post',
@@ -186,7 +187,8 @@ to specify the file's MIME type explicitly::
For sending raw binary data simply specify the ``body`` argument. It's also
recommended to set the ``Content-Type`` header::
- >>> binary_data = open('example.jpg', 'rb').read()
+ >>> with open('example.jpg', 'rb') as fp:
+ ... binary_data = fp.read()
>>> r = http.request(
... 'POST',
... 'http://httpbin.org/post',