Skip to content
Myr

Merge pull request #1231 from davidfischer/docs-migration1.0

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

Initial docs patch for migrating from pre 1.0

authored by Kenneth Reitz · committed by Kenneth Reitz · parents be62645, 7e7c275 · Browse files · 1 file+71 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+71 added−0 removed

  • other:+71 added−0 removed

1 file+71 added−0 removed

modified:docs/api.rst+71 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 s = requests.Session() # formerly, session took parameters133 s.auth = auth134 s.headers.update(headers)135 r = s.get('http://httpbin.org/headers')136137* All request hooks have been removed except 'response'.138139* Authentication helpers have been broken out into separate modules. See140 requests-oauthlib_ and requests-kerberos_.141142.. _requests-oauthlib: https://github.com/requests/requests-oauthlib143.. _requests-kerberos: https://github.com/requests/requests-kerberos144145* The parameter for streaming requests was changed from ``prefetch`` to146 ``stream`` and the logic was inverted. In addition, ``stream`` is now147 required for raw response reading.148149 ::150151 # in 0.x, passing prefetch=False would accomplish the same thing152 r = requests.get('https://github.com/timeline.json', stream=True)153 r.raw.read(10)154155* The ``config`` parameter to the requests method has been removed. Some of156 these options are now configured on a ``Session`` such as keep-alive and157 maximum number of redirects. The verbosity option should be handled by158 configuring logging.159160 ::161162 # Verbosity should now be configured with logging163 my_config = {'verbose': sys.stderr}164 requests.get('http://httpbin.org/headers', config=my_config) # bad!165166167Licensing168~~~~~~~~~169170One key difference that has nothing to do with the API is a change in the171license from the ISC_ license to the `Apache 2.0`_ license. The Apache 2.0172license ensures that contributions to requests are also covered by the Apache1732.0 license.174175.. _ISC: http://opensource.org/licenses/ISC176.. _Apache 2.0: http://opensource.org/licenses/Apache-2.0177