Added migrating to 2.x docs
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 4401620 · Browse files · 1 file·+64 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+64 added−0 removed
- other:+64 added−0 removed
Provenance
- Commit
fbb8d32- Tree
c502312- Author
David Fischer <djfische@gmail.com>- Committer
David Fischer <djfische@gmail.com>- Parent
4401620
1 file changed+64 added−0 removed
modified:docs/api.rst+64 added
191 unmodified lines192 193 .. _ISC: http://opensource.org/licenses/ISC194 .. _Apache 2.0: http://opensource.org/licenses/Apache-2.0195 196+197+Migrating to 2.x198+----------------199+200+201+Compared with the 1.0 release, there were relatively few backwards202+incompatible changes, but there are still a few issues to be aware of with203+this major release.204+205+206+API Changes207+~~~~~~~~~~~208+209+* There were a couple changes to how Requests handles exceptions.210+ ``RequestException`` is now a subclass of ``IOError`` rather than211+ ``RuntimeError`` as that more accurately categorizes the type of error.212+ In addition, an invalid URL escape sequence now raises a subclass of213+ ``RequestException`` rather than a ``ValueError``.214+215+ ::216+217+ requests.get('http://%zz/') # raises requests.exceptions.InvalidURL218+219+ Lastly, ``httplib.IncompleteRead`` exceptions caused by incorrect chunked220+ encoding will now raise a Requests ``ChunkedEncodingError`` instead.221+222+* The proxy API has changed slightly. The scheme for a proxy URL is now223+ required.224+225+ ::226+227+ proxies = {228+ "http": "10.10.1.10:3128", # use http://10.10.1.10:3128 instead229+ }230+231+ # In requests 1.x, this was legal, in requests 2.x,232+ # this raises requests.exceptions.MissingSchema233+ requests.get("http://example.org", proxies=proxies)234+235+236+Behavioral Changes237+~~~~~~~~~~~~~~~~~~238+239+* Keys in the ``headers`` dictionary are now native strings on all Python240+ versions, i.e. bytestrings on Python 2 and unicode on Python 3. If the241+ keys are not native strings (unicode on Python2 or bytestrings on Python 3)242+ they will be converted to the native string type assuming UTF-8 encoding.243+244+* Timeouts behave slightly differently. On streaming requests, the timeout245+ only applies to the connection attempt. On regular requests, the timeout246+ is applied to the connection process and downloading the full body.247+248+ ::249+250+ tarball_url = 'https://github.com/kennethreitz/requests/tarball/master'251+252+ # One second timeout for the connection attempt253+ # Unlimited time to download the tarball254+ r = requests.get(tarball_url, stream=True, timeout=1)255+256+ # One second timeout for the connection attempt257+ # Another full second timeout to download the tarball258+ r = requests.get(tarball_url, timeout=1)259+