Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
PyPI

requests-toolbelt 1.0.0

pip install requests-toolbelt

Latest version

Released:

A utility belt for advanced users of python-requests

Verified details

These details have beenverified by PyPI
Maintainers
Avatar for graffatcolmingov from gravatar.comgraffatcolmingovAvatar for quentinp from gravatar.comquentinp

Unverified details

These details havenot been verified by PyPI
Project links
Meta
  • License: Apache Software License (Apache 2.0)
  • Author:Ian Cordasco, Cory Benfield
  • Requires: Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*

Project description

The Requests Toolbelt

This is just a collection of utilities forpython-requests, but don’treally belong inrequests proper. The minimum tested requests version is2.1.0. In reality, the toolbelt should work with2.0.1 as well, butsome idiosyncracies prevent effective or sane testing on that version.

pip installrequests-toolbelt to get started!

multipart/form-data Encoder

The main attraction is a streaming multipart form-data object,MultipartEncoder.Its API looks like this:

fromrequests_toolbeltimportMultipartEncoderimportrequestsm=MultipartEncoder(fields={'field0':'value','field1':'value','field2':('filename',open('file.py','rb'),'text/plain')})r=requests.post('http://httpbin.org/post',data=m,headers={'Content-Type':m.content_type})

You can also usemultipart/form-data encoding for requests that don’trequire files:

fromrequests_toolbeltimportMultipartEncoderimportrequestsm=MultipartEncoder(fields={'field0':'value','field1':'value'})r=requests.post('http://httpbin.org/post',data=m,headers={'Content-Type':m.content_type})

Or, you can just create the string and examine the data:

# Assuming `m` is one of the abovem.to_string()# Always returns unicode

User-Agent constructor

You can easily construct a requests-styleUser-Agent string:

from requests_toolbelt import user_agentheaders = {    'User-Agent': user_agent('my_package', '0.0.1')    }r = requests.get('https://api.github.com/users', headers=headers)

SSLAdapter

TheSSLAdapter was originally published onCory Benfield’s blog.This adapter allows the user to choose one of the SSL protocols made availablein Python’sssl module for outgoing HTTPS connections:

fromrequests_toolbeltimportSSLAdapterimportrequestsimportssls=requests.Session()s.mount('https://',SSLAdapter(ssl.PROTOCOL_TLSv1))

cookies/ForgetfulCookieJar

TheForgetfulCookieJar prevents a particular requests session from storingcookies:

fromrequests_toolbelt.cookies.forgetfulimportForgetfulCookieJarsession=requests.Session()session.cookies=ForgetfulCookieJar()

Contributing

Please read thesuggested workflow forcontributing to this project.

Please report any bugs on theissue tracker

History

1.0.0 – 2023-05-01

Breaking Changes

  • Removed Google App Engine support to allow using urllib3 2.0

Fixed Bugs

  • Ensured the test suite no longer reaches the Internet

Miscellaneous

  • Added explicit support for Python 3.11

0.10.1 – 2022-10-25

Fixed Bugs

  • Fix urllib3 warning to only emit on X509Adapter usage

0.10.0 – 2022-10-06

New Features

  • Add support for preparing requests in BaseUrlSession

Fixed Bugs

  • Fixing missing newline in dump utility

0.9.1 – 2019-01-29

Fixed Bugs

  • Fix import of pyOpenSSL shim from urllib3 for PKCS12 adapter

0.9.0 – 2019-01-29

New Features

  • Add X509 Adapter that can handle PKCS12

  • Add stateless solution for streaming files by MultipartEncoder from one host to another (in chunks)

Fixed Bugs

  • Update link to example

  • Move import ofABCs from collections into version-specific part of_compat module

  • Fix backwards incompatibility inget_encodings_from_content

  • Correct callback documentation forMultipartEncoderMonitor

  • Fix bug whenMultipartEncoder is asked to encode zero parts

  • Correct the type of non string request body dumps

  • Removed content from being stored in MultipartDecoder

  • Fix bug by enabling support for contenttype with capital letters.

  • Coerce proxy URL to bytes before dumping request

  • Avoid bailing out with exception upon empty response reason

  • Corrected Pool documentation

  • Corrected parentheses match in example usage

  • Fix “oject” to “object” inMultipartEncoder

  • Fix URL for the project after the move

  • Add fix for OSX TCPKeepAliveAdapter

Miscellaneous

  • Remove py33 from testing and add Python 3.6 and nightly testing to the travis matrix.

0.8.0 – 2017-05-20

More information about this release can be found on the0.8.0 milestone.

New Features

  • AddUserAgentBuilder to provide more control over generated User-Agentstrings.

Fixed Bugs

  • Include_validate_certificate in the lits of picked attributes on theAppEngineAdapter.

  • Fix backwards incompatibility inget_encodings_from_content

0.7.1 – 2017-02-13

More information about this release can be found on the0.7.1 milestone.

Fixed Bugs

  • Fixed monkey-patching for the AppEngineAdapter.

  • Make it easier to disable certificate verification when monkey-patchingAppEngine.

  • Handlemultipart/form-data bodies without a trailingCRLF.

0.7.0 – 2016-07-21

More information about this release can be found on the0.7.0 milestone.

New Features

  • AddBaseUrlSession to allow developers to have a session that has a“Base” URL. See the documentation for more details and examples.

  • Split the logic ofstream_response_to_file into two separate functions:

    • get_download_file_path to generate the file name from the Response.

    • stream_response_to_file which will useget_download_file_path ifnecessary

Fixed Bugs

  • Fixed the issue for people usingvery old versions of Requests where theywould see an ImportError fromrequests_toolbelt._compat when trying toimportconnection.

0.6.2 – 2016-05-10

Fixed Bugs

  • When passing a timeout via Requests, it was not appropriately translated tothe timeout that the urllib3 code was expecting.

0.6.1 – 2016-05-05

Fixed Bugs

  • Remove assertion about request URLs in the AppEngineAdapter.

  • Prevent pip from installing requests 3.0.0 when that is released until weare ready to handle it.

0.6.0 – 2016-01-27

More information about this release can be found on the0.6.0 milestone.

New Features

  • AddAppEngineAdapter to support developers using Google’s AppEngineplatform with Requests.

  • AddGuessProxyAuth class to support guessing between Basic and DigestAuthentication for proxies.

Fixed Bugs

  • Ensure that proxies use the correct TLS version when using theSSLAdapter.

  • Fix anAttributeError when using theHTTPProxyDigestAuth class.

Miscellaneous

  • Drop testing support for Python 3.2. virtualenv and pip have stoppedsupporting it meaning that it is harder to test for this with our CIinfrastructure. Moving forward we will make a best-effort attempt tosupport 3.2 but will not test for it.

0.5.1 – 2015-12-16

More information about this release can be found on the0.5.1 milestone.

Fixed Bugs

  • Now papers over the differences in requests’super_len function fromversions prior to 2.9.0 and versions 2.9.0 and later.

0.5.0 – 2015-11-24

More information about this release can be found on themilestonefor 0.5.0.

New Features

  • Thetee submodule was added torequests_toolbelt.downloadutils. Itallows you to iterate over the bytes of a response while also writing themto a file. Thetee.tee function, expects you to pass an open fileobject, whiletee.tee_to_file will use the provided file name to openthe file for you.

  • Added a new parameter torequests_toolbelt.utils.user_agent that allowsthe user to specify additional items.

  • Added nested form-data helper,requests_toolbelt.utils.formdata.urlencode.

  • Added theForgetfulCookieJar torequests_toolbelt.cookies.

  • Added utilities for dumping the information about a request-response cycleinrequests_toolbelt.utils.dump.

  • Implemented the API described in therequests_toolbelt.threaded moduledocstring, i.e., addedrequests_toolbelt.threaded.map as an availablefunction.

Fixed Bugs

  • Now papers over the API differences in versions of requests installed fromsystem packages versus versions of requests installed from PyPI.

  • Allow string types forSourceAddressAdapter.

0.4.0 – 2015-04-03

For more information about this release, please seemilestone 0.4.0on the project’s page.

New Features

  • A naive implemenation of a thread pool is now included in the toolbelt. Seethe docs indocs/threading.rst or onRead The Docs.

  • TheStreamingIterator now accepts files (such assys.stdin) withouta specific length and will properly stream them.

  • TheMultipartEncoder now accepts exactly the same format of fields asrequests’files parameter does. In other words, you can now also pass inextra headers to add to a part in the body. You can also now specify acustomContent-Type for a part.

  • An implementation of HTTP Digest Authentication for Proxies is now included.

  • A transport adapter that allows a user to specify a specific CertificateFingerprint is now included in the toolbelt.

  • A transport adapter that simplifies how users specify socket options is nowincluded.

  • A transport adapter that simplifies how users can specify TCP Keep-Aliveoptions is now included in the toolbelt.

  • Deprecated functions fromrequests.utils are now included andmaintained.

  • An authentication tool that allows users to specify how to authenticate toseveral different domains at once is now included.

  • A function to save streamed responses to disk by analyzing theContent-Disposition header is now included in the toolbelt.

Fixed Bugs

  • TheMultipartEncoder will now allow users to upload files larger than4GB on 32-bit systems.

  • TheMultipartEncoder will now accept empty unicode strings for formvalues.

0.3.1 – 2014-06-23

  • Fix the fact that 0.3.0 bundle did not include theStreamingIterator

0.3.0 – 2014-05-21

Bug Fixes

  • Complete rewrite ofMultipartEncoder fixes bug where bytes were lost inuploads

New Features

  • MultipartDecoder to acceptmultipart/form-data response bodies andparse them into an easy to use object.

  • SourceAddressAdapter to allow users to choose a local address to bindconnections to.

  • GuessAuth which accepts a username and password and uses theWWW-Authenticate header to determine how to authenticate against aserver.

  • MultipartEncoderMonitor wraps an instance of theMultipartEncoderand keeps track of how many bytes were read and will call the providedcallback.

  • StreamingIterator will wrap an iterator and stream the upload instead ofchunk it, provided you also provide the length of the content you wish toupload.

0.2.0 – 2014-02-24

  • Add ability to tellMultipartEncoder which encoding to use. By defaultit uses ‘utf-8’.

  • Fix #10 - allow users to install with pip

  • Fix #9 - FixMultipartEncoder#to_string so that it properly handles fileobjects as fields

0.1.2 – 2014-01-19

  • At some point during development we broke how we handle normal file objects.Thanks to @konomae this is now fixed.

0.1.1 – 2014-01-19

  • Handleio.BytesIO-like objects better

0.1.0 – 2014-01-18

  • Add initial implementation of the streamingMultipartEncoder

  • Add initial implementation of theuser_agent function

  • Add theSSLAdapter

Project details

Verified details

These details have beenverified by PyPI
Maintainers
Avatar for graffatcolmingov from gravatar.comgraffatcolmingovAvatar for quentinp from gravatar.comquentinp

Unverified details

These details havenot been verified by PyPI
Project links
Meta
  • License: Apache Software License (Apache 2.0)
  • Author:Ian Cordasco, Cory Benfield
  • Requires: Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*

Download files

Download the file for your platform. If you're not sure which to choose, learn more aboutinstalling packages.

Source Distribution

requests-toolbelt-1.0.0.tar.gz (206.9 kBview details)

UploadedSource

Built Distribution

Filter files by name, interpreter, ABI, and platform.

If you're not sure about the file name format, learn more aboutwheel file names.

Copy a direct link to the current filters

requests_toolbelt-1.0.0-py2.py3-none-any.whl (54.5 kBview details)

UploadedPython 2Python 3

File details

Details for the filerequests-toolbelt-1.0.0.tar.gz.

File metadata

  • Download URL:requests-toolbelt-1.0.0.tar.gz
  • Upload date:
  • Size: 206.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for requests-toolbelt-1.0.0.tar.gz
AlgorithmHash digest
SHA2567681a0a3d047012b5bdc0ee37d7f8f07ebe76ab08caeccfc3921ce23c88d5bc6
MD56a8348cfc9991b44e499345db1c6f925
BLAKE2b-256f361d7545dafb7ac2230c70d38d31cbfe4cc64f7144dc41f6e4e4b78ecd9f5bb

See more details on using hashes here.

File details

Details for the filerequests_toolbelt-1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for requests_toolbelt-1.0.0-py2.py3-none-any.whl
AlgorithmHash digest
SHA256cccfdd665f0a24fcf4726e690f65639d272bb0637b9b92dfd91a5568ccf6bd06
MD5a85998b5e6620919a7e79e854128fae4
BLAKE2b-2563f51d4db610ef29373b879047326cbf6fa98b6c1969d6f6dc423279de2b1be2c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security SponsorDatadog MonitoringDepot Continuous IntegrationFastly CDNGoogle Download AnalyticsPingdom MonitoringSentry Error loggingStatusPage Status page

[8]ページ先頭

©2009-2025 Movatter.jp