METADATA 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. Metadata-Version: 2.1
  2. Name: requests-toolbelt
  3. Version: 0.9.1
  4. Summary: A utility belt for advanced users of python-requests
  5. Home-page: https://toolbelt.readthedocs.org
  6. Author: Ian Cordasco, Cory Benfield
  7. Author-email: graffatcolmingov@gmail.com
  8. License: Apache 2.0
  9. Platform: UNKNOWN
  10. Classifier: Development Status :: 5 - Production/Stable
  11. Classifier: License :: OSI Approved :: Apache Software License
  12. Classifier: Intended Audience :: Developers
  13. Classifier: Programming Language :: Python
  14. Classifier: Programming Language :: Python :: 2
  15. Classifier: Programming Language :: Python :: 2.7
  16. Classifier: Programming Language :: Python :: 3
  17. Classifier: Programming Language :: Python :: 3.3
  18. Classifier: Programming Language :: Python :: 3.4
  19. Classifier: Programming Language :: Python :: 3.5
  20. Classifier: Programming Language :: Python :: Implementation :: CPython
  21. Requires-Dist: requests (<3.0.0,>=2.0.1)
  22. The Requests Toolbelt
  23. =====================
  24. This is just a collection of utilities for `python-requests`_, but don't
  25. really belong in ``requests`` proper. The minimum tested requests version is
  26. ``2.1.0``. In reality, the toolbelt should work with ``2.0.1`` as well, but
  27. some idiosyncracies prevent effective or sane testing on that version.
  28. ``pip install requests-toolbelt`` to get started!
  29. multipart/form-data Encoder
  30. ---------------------------
  31. The main attraction is a streaming multipart form-data object, ``MultipartEncoder``.
  32. Its API looks like this:
  33. .. code-block:: python
  34. from requests_toolbelt import MultipartEncoder
  35. import requests
  36. m = MultipartEncoder(
  37. fields={'field0': 'value', 'field1': 'value',
  38. 'field2': ('filename', open('file.py', 'rb'), 'text/plain')}
  39. )
  40. r = requests.post('http://httpbin.org/post', data=m,
  41. headers={'Content-Type': m.content_type})
  42. You can also use ``multipart/form-data`` encoding for requests that don't
  43. require files:
  44. .. code-block:: python
  45. from requests_toolbelt import MultipartEncoder
  46. import requests
  47. m = MultipartEncoder(fields={'field0': 'value', 'field1': 'value'})
  48. r = requests.post('http://httpbin.org/post', data=m,
  49. headers={'Content-Type': m.content_type})
  50. Or, you can just create the string and examine the data:
  51. .. code-block:: python
  52. # Assuming `m` is one of the above
  53. m.to_string() # Always returns unicode
  54. User-Agent constructor
  55. ----------------------
  56. You can easily construct a requests-style ``User-Agent`` string::
  57. from requests_toolbelt import user_agent
  58. headers = {
  59. 'User-Agent': user_agent('my_package', '0.0.1')
  60. }
  61. r = requests.get('https://api.github.com/users', headers=headers)
  62. SSLAdapter
  63. ----------
  64. The ``SSLAdapter`` was originally published on `Cory Benfield's blog`_.
  65. This adapter allows the user to choose one of the SSL protocols made available
  66. in Python's ``ssl`` module for outgoing HTTPS connections:
  67. .. code-block:: python
  68. from requests_toolbelt import SSLAdapter
  69. import requests
  70. import ssl
  71. s = requests.Session()
  72. s.mount('https://', SSLAdapter(ssl.PROTOCOL_TLSv1))
  73. cookies/ForgetfulCookieJar
  74. --------------------------
  75. The ``ForgetfulCookieJar`` prevents a particular requests session from storing
  76. cookies:
  77. .. code-block:: python
  78. from requests_toolbelt.cookies.forgetful import ForgetfulCookieJar
  79. session = requests.Session()
  80. session.cookies = ForgetfulCookieJar()
  81. Known Issues
  82. ------------
  83. On Python 3.3.0 and 3.3.1, the standard library's ``http`` module will fail
  84. when passing an instance of the ``MultipartEncoder``. This is fixed in later
  85. minor releases of Python 3.3. Please consider upgrading to a later minor
  86. version or Python 3.4. *There is absolutely nothing this library can do to
  87. work around that bug.*
  88. Contributing
  89. ------------
  90. Please read the `suggested workflow
  91. <https://toolbelt.readthedocs.org/en/latest/contributing.html>`_ for
  92. contributing to this project.
  93. Please report any bugs on the `issue tracker`_
  94. .. _Cory Benfield's blog: https://lukasa.co.uk/2013/01/Choosing_SSL_Version_In_Requests/
  95. .. _python-requests: https://github.com/kennethreitz/requests
  96. .. _issue tracker: https://github.com/requests/toolbelt/issues
  97. History
  98. =======
  99. 0.9.1 -- 2019-01-29
  100. -------------------
  101. Fixed Bugs
  102. ~~~~~~~~~~
  103. - Fix import of pyOpenSSL shim from urllib3 for PKCS12 adapter
  104. 0.9.0 -- 2019-01-29
  105. -------------------
  106. New Features
  107. ~~~~~~~~~~~~
  108. - Add X509 Adapter that can handle PKCS12
  109. - Add stateless solution for streaming files by MultipartEncoder from one host to another (in chunks)
  110. Fixed Bugs
  111. ~~~~~~~~~~
  112. - Update link to example
  113. - Move import of ``ABCs`` from collections into version-specific part of
  114. _compat module
  115. - Fix backwards incompatibility in ``get_encodings_from_content``
  116. - Correct callback documentation for ``MultipartEncoderMonitor``
  117. - Fix bug when ``MultipartEncoder`` is asked to encode zero parts
  118. - Correct the type of non string request body dumps
  119. - Removed content from being stored in MultipartDecoder
  120. - Fix bug by enabling support for contenttype with capital letters.
  121. - Coerce proxy URL to bytes before dumping request
  122. - Avoid bailing out with exception upon empty response reason
  123. - Corrected Pool documentation
  124. - Corrected parentheses match in example usage
  125. - Fix "oject" to "object" in ``MultipartEncoder``
  126. - Fix URL for the project after the move
  127. - Add fix for OSX TCPKeepAliveAdapter
  128. Miscellaneous
  129. ~~~~~~~~~~~~~
  130. - Remove py33 from testing and add Python 3.6 and nightly testing to the travis matrix.
  131. 0.8.0 -- 2017-05-20
  132. -------------------
  133. More information about this release can be found on the `0.8.0 milestone`_.
  134. New Features
  135. ~~~~~~~~~~~~
  136. - Add ``UserAgentBuilder`` to provide more control over generated User-Agent
  137. strings.
  138. Fixed Bugs
  139. ~~~~~~~~~~
  140. - Include ``_validate_certificate`` in the lits of picked attributes on the
  141. ``AppEngineAdapter``.
  142. - Fix backwards incompatibility in ``get_encodings_from_content``
  143. .. _0.8.0 milestone:
  144. https://github.com/requests/toolbelt/milestones/0.8.0
  145. 0.7.1 -- 2017-02-13
  146. -------------------
  147. More information about this release can be found on the `0.7.1 milestone`_.
  148. Fixed Bugs
  149. ~~~~~~~~~~
  150. - Fixed monkey-patching for the AppEngineAdapter.
  151. - Make it easier to disable certificate verification when monkey-patching
  152. AppEngine.
  153. - Handle ``multipart/form-data`` bodies without a trailing ``CRLF``.
  154. .. links
  155. .. _0.7.1 milestone:
  156. https://github.com/requests/toolbelt/milestone/9
  157. 0.7.0 -- 2016-07-21
  158. -------------------
  159. More information about this release can be found on the `0.7.0 milestone`_.
  160. New Features
  161. ~~~~~~~~~~~~
  162. - Add ``BaseUrlSession`` to allow developers to have a session that has a
  163. "Base" URL. See the documentation for more details and examples.
  164. - Split the logic of ``stream_response_to_file`` into two separate functions:
  165. * ``get_download_file_path`` to generate the file name from the Response.
  166. * ``stream_response_to_file`` which will use ``get_download_file_path`` if
  167. necessary
  168. Fixed Bugs
  169. ~~~~~~~~~~
  170. - Fixed the issue for people using *very* old versions of Requests where they
  171. would see an ImportError from ``requests_toolbelt._compat`` when trying to
  172. import ``connection``.
  173. .. _0.7.0 milestone:
  174. https://github.com/requests/toolbelt/milestones/0.7.0
  175. 0.6.2 -- 2016-05-10
  176. -------------------
  177. Fixed Bugs
  178. ~~~~~~~~~~
  179. - When passing a timeout via Requests, it was not appropriately translated to
  180. the timeout that the urllib3 code was expecting.
  181. 0.6.1 -- 2016-05-05
  182. -------------------
  183. Fixed Bugs
  184. ~~~~~~~~~~
  185. - Remove assertion about request URLs in the AppEngineAdapter.
  186. - Prevent pip from installing requests 3.0.0 when that is released until we
  187. are ready to handle it.
  188. 0.6.0 -- 2016-01-27
  189. -------------------
  190. More information about this release can be found on the `0.6.0 milestone`_.
  191. New Features
  192. ~~~~~~~~~~~~
  193. - Add ``AppEngineAdapter`` to support developers using Google's AppEngine
  194. platform with Requests.
  195. - Add ``GuessProxyAuth`` class to support guessing between Basic and Digest
  196. Authentication for proxies.
  197. Fixed Bugs
  198. ~~~~~~~~~~
  199. - Ensure that proxies use the correct TLS version when using the
  200. ``SSLAdapter``.
  201. - Fix an ``AttributeError`` when using the ``HTTPProxyDigestAuth`` class.
  202. Miscellaneous
  203. ~~~~~~~~~~~~~
  204. - Drop testing support for Python 3.2. virtualenv and pip have stopped
  205. supporting it meaning that it is harder to test for this with our CI
  206. infrastructure. Moving forward we will make a best-effort attempt to
  207. support 3.2 but will not test for it.
  208. .. _0.6.0 milestone:
  209. https://github.com/requests/toolbelt/milestones/0.6.0
  210. 0.5.1 -- 2015-12-16
  211. -------------------
  212. More information about this release can be found on the `0.5.1 milestone`_.
  213. Fixed Bugs
  214. ~~~~~~~~~~
  215. - Now papers over the differences in requests' ``super_len`` function from
  216. versions prior to 2.9.0 and versions 2.9.0 and later.
  217. .. _0.5.1 milestone:
  218. https://github.com/requests/toolbelt/milestones/0.5.1
  219. 0.5.0 -- 2015-11-24
  220. -------------------
  221. More information about this release can be found on the `milestone
  222. <https://github.com/requests/toolbelt/issues?utf8=%E2%9C%93&q=is%3Aall+milestone%3A0.5+>`_
  223. for 0.5.0.
  224. New Features
  225. ~~~~~~~~~~~~
  226. - The ``tee`` submodule was added to ``requests_toolbelt.downloadutils``. It
  227. allows you to iterate over the bytes of a response while also writing them
  228. to a file. The ``tee.tee`` function, expects you to pass an open file
  229. object, while ``tee.tee_to_file`` will use the provided file name to open
  230. the file for you.
  231. - Added a new parameter to ``requests_toolbelt.utils.user_agent`` that allows
  232. the user to specify additional items.
  233. - Added nested form-data helper,
  234. ``requests_toolbelt.utils.formdata.urlencode``.
  235. - Added the ``ForgetfulCookieJar`` to ``requests_toolbelt.cookies``.
  236. - Added utilities for dumping the information about a request-response cycle
  237. in ``requests_toolbelt.utils.dump``.
  238. - Implemented the API described in the ``requests_toolbelt.threaded`` module
  239. docstring, i.e., added ``requests_toolbelt.threaded.map`` as an available
  240. function.
  241. Fixed Bugs
  242. ~~~~~~~~~~
  243. - Now papers over the API differences in versions of requests installed from
  244. system packages versus versions of requests installed from PyPI.
  245. - Allow string types for ``SourceAddressAdapter``.
  246. 0.4.0 -- 2015-04-03
  247. -------------------
  248. For more information about this release, please see `milestone 0.4.0
  249. <https://github.com/requests/toolbelt/issues?q=milestone%3A0.4>`_
  250. on the project's page.
  251. New Features
  252. ~~~~~~~~~~~~
  253. - A naive implemenation of a thread pool is now included in the toolbelt. See
  254. the docs in ``docs/threading.rst`` or on `Read The Docs
  255. <https://toolbelt.readthedocs.org>`_.
  256. - The ``StreamingIterator`` now accepts files (such as ``sys.stdin``) without
  257. a specific length and will properly stream them.
  258. - The ``MultipartEncoder`` now accepts exactly the same format of fields as
  259. requests' ``files`` parameter does. In other words, you can now also pass in
  260. extra headers to add to a part in the body. You can also now specify a
  261. custom ``Content-Type`` for a part.
  262. - An implementation of HTTP Digest Authentication for Proxies is now included.
  263. - A transport adapter that allows a user to specify a specific Certificate
  264. Fingerprint is now included in the toolbelt.
  265. - A transport adapter that simplifies how users specify socket options is now
  266. included.
  267. - A transport adapter that simplifies how users can specify TCP Keep-Alive
  268. options is now included in the toolbelt.
  269. - Deprecated functions from ``requests.utils`` are now included and
  270. maintained.
  271. - An authentication tool that allows users to specify how to authenticate to
  272. several different domains at once is now included.
  273. - A function to save streamed responses to disk by analyzing the
  274. ``Content-Disposition`` header is now included in the toolbelt.
  275. Fixed Bugs
  276. ~~~~~~~~~~
  277. - The ``MultipartEncoder`` will now allow users to upload files larger than
  278. 4GB on 32-bit systems.
  279. - The ``MultipartEncoder`` will now accept empty unicode strings for form
  280. values.
  281. 0.3.1 -- 2014-06-23
  282. -------------------
  283. - Fix the fact that 0.3.0 bundle did not include the ``StreamingIterator``
  284. 0.3.0 -- 2014-05-21
  285. -------------------
  286. Bug Fixes
  287. ~~~~~~~~~
  288. - Complete rewrite of ``MultipartEncoder`` fixes bug where bytes were lost in
  289. uploads
  290. New Features
  291. ~~~~~~~~~~~~
  292. - ``MultipartDecoder`` to accept ``multipart/form-data`` response bodies and
  293. parse them into an easy to use object.
  294. - ``SourceAddressAdapter`` to allow users to choose a local address to bind
  295. connections to.
  296. - ``GuessAuth`` which accepts a username and password and uses the
  297. ``WWW-Authenticate`` header to determine how to authenticate against a
  298. server.
  299. - ``MultipartEncoderMonitor`` wraps an instance of the ``MultipartEncoder``
  300. and keeps track of how many bytes were read and will call the provided
  301. callback.
  302. - ``StreamingIterator`` will wrap an iterator and stream the upload instead of
  303. chunk it, provided you also provide the length of the content you wish to
  304. upload.
  305. 0.2.0 -- 2014-02-24
  306. -------------------
  307. - Add ability to tell ``MultipartEncoder`` which encoding to use. By default
  308. it uses 'utf-8'.
  309. - Fix #10 - allow users to install with pip
  310. - Fix #9 - Fix ``MultipartEncoder#to_string`` so that it properly handles file
  311. objects as fields
  312. 0.1.2 -- 2014-01-19
  313. -------------------
  314. - At some point during development we broke how we handle normal file objects.
  315. Thanks to @konomae this is now fixed.
  316. 0.1.1 -- 2014-01-19
  317. -------------------
  318. - Handle ``io.BytesIO``-like objects better
  319. 0.1.0 -- 2014-01-18
  320. -------------------
  321. - Add initial implementation of the streaming ``MultipartEncoder``
  322. - Add initial implementation of the ``user_agent`` function
  323. - Add the ``SSLAdapter``