Skip to content
Myr

Initial docs patch for migrating from pre 1.0

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Fischer · committed by David Fischer · parent be62645 · Browse files · 1 file+70 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+70 added−0 removed

  • other:+70 added−0 removed

1 file+70 added−0 removed

modified:docs/api.rst+70 added
102 unmodified lines
103104.. autoclass:: requests.Session105 :inherited-members:106107108Migrating to 1.x109----------------110111This section details the main differences between 0.x and 1.x and is meant112to ease the pain of upgrading.113114115API Changes116~~~~~~~~~~~117118* ``Response.json`` is now a callable and not a property of a response.119120 ::121122 import requests123 r = requests.get('https://github.com/timeline.json')124 r.json() # This *call* raises an exception if JSON decoding fails125126* The ``Session`` API has changed. Sessions objects no longer take parameters.127 ``Session`` is also now capitalized, but it can still be128 instantiated with a lowercase ``session`` for backwards compatibility.129130 ::131132 with requests.session() as s: # formerly, session took parameters133 s.auth = auth134 s.headers.update(headers)135136* All request hooks have been removed except 'response'.137138* Authentication helpers have been broken out into separate modules. See139 requests-oauthlib_ and requests-kerberos_.140141.. _requests-oauthlib: https://github.com/requests/requests-oauthlib142.. _requests-kerberos: https://github.com/requests/requests-kerberos143144* The parameter for streaming requests was changed from ``prefetch`` to145 ``stream``. In addition, the stream parameter is required for raw response146 reading.147148 ::149150 # in 0.x, the "stream" parameter was called "prefetch"151 r = requests.get('https://github.com/timeline.json', stream=True)152 r.raw.read(10)153154* The ``config`` parameter to the requests method has been removed. Some of155 these options are now configured on a ``Session`` such as keep-alive and156 maximum number of redirects. The verbosity option should be handled by157 configuring logging.158159 ::160161 # Verbosity should now be configured with logging162 my_config = {'verbose': sys.stderr}163 requests.get('http://httpbin.org/headers', config=my_config) # bad!164165166Licensing167~~~~~~~~~168169One key difference that has nothing to do with the API is a change in the170license from the ISC_ license to the `Apache 2.0`_ license. The Apache 2.0171license ensures that contributions to requests are also covered by the Apache1722.0 license.173174.. _ISC: http://opensource.org/licenses/ISC175.. _Apache 2.0: http://opensource.org/licenses/Apache-2.0176