METADATA 14 KB

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