Skip to content

Commit

Permalink
Merge branch 'master' into 5367
Browse files Browse the repository at this point in the history
  • Loading branch information
mondeja committed Jul 22, 2020
2 parents 50c985b + 1b41763 commit 47cb6fc
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 30 deletions.
19 changes: 17 additions & 2 deletions HISTORY.md
Expand Up @@ -4,10 +4,25 @@ Release History
dev
---

**Bugfixes**

- \[Short description of non-trivial change.\]

2.24.0 (2020-06-17)
-------------------

**Improvements**

- pyOpenSSL TLS implementation is now only used if Python
either doesn't have an `ssl` module or doesn't support
SNI. Previously pyOpenSSL was unconditionally used if available.
This applies even if pyOpenSSL is installed via the
`requests[security]` extra (#5443)

- Redirect resolution should now only occur when
`allow_redirects` is True. (#5492)

- No longer perform unnecessary Content-Length calculation for
requests that won't use it. (#5496)

2.23.0 (2020-02-19)
-------------------

Expand Down
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -28,7 +28,7 @@ by <a href="https://kennethreitz.org/">Kenneth Reitz</a> & is protected by The <

<p>&nbsp;</p>

```pycon
```python
>>> import requests
>>> r = requests.get('https://api.github.com/user', auth=('user', 'pass'))
>>> r.status_code
Expand All @@ -52,7 +52,7 @@ by <a href="https://kennethreitz.org/">Kenneth Reitz</a> & is protected by The <
Requests allows you to send HTTP/1.1 requests extremely easily. There’s no need to manually add query strings to your URLs, or to form-encode your `PUT` & `POST` data — but nowadays, just use the `json` method!


Requests is **the most downloaded Python package today**, pulling in around `14M downloads / week`— according to GitHub, Requests is currently [depended upon](https://github.com/psf/requests/network/dependents?package_id=UGFja2FnZS01NzA4OTExNg%3D%3D) by `367_296` repositories. You may certainly put your trust in this code.
Requests is one of the most downloaded Python package today, pulling in around `14M downloads / week`— according to GitHub, Requests is currently [depended upon](https://github.com/psf/requests/network/dependents?package_id=UGFja2FnZS01NzA4OTExNg%3D%3D) by `500,000+` repositories. You may certainly put your trust in this code.


<p>&nbsp;</p>
Expand Down Expand Up @@ -89,7 +89,7 @@ Requests is ready for the demands of building robust and reliable HTTP–speak a
Requests Module Installation
----------------------------

The recommended way to intall the `requests` module is to simply use [`pipenv`](https://pipenv.kennethreitz.org) (or `pip`, of
The recommended way to install the `requests` module is to simply use [`pipenv`](https://pipenv.kennethreitz.org) (or `pip`, of
course):

```console
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/todo.rst
Expand Up @@ -58,7 +58,7 @@ Requests currently supports the following versions of Python:
- Python 3.7
- PyPy

Google AppEngine is not officially supported although support is available
Google App Engine is not officially supported although support is available
with the `Requests-Toolbelt`_.

.. _Requests-Toolbelt: https://toolbelt.readthedocs.io/
2 changes: 0 additions & 2 deletions docs/user/advanced.rst
Expand Up @@ -3,8 +3,6 @@
Advanced Usage
==============

.. image:: https://farm5.staticflickr.com/4263/35163665790_d182d84f5e_k_d.jpg

This document covers some of Requests more advanced features.

.. _session-objects:
Expand Down
20 changes: 14 additions & 6 deletions requests/__init__.py
Expand Up @@ -90,14 +90,22 @@ def _check_cryptography(cryptography_version):
"version!".format(urllib3.__version__, chardet.__version__),
RequestsDependencyWarning)

# Attempt to enable urllib3's SNI support, if possible
# Attempt to enable urllib3's fallback for SNI support
# if the standard library doesn't support SNI or the
# 'ssl' library isn't available.
try:
from urllib3.contrib import pyopenssl
pyopenssl.inject_into_urllib3()
try:
import ssl
except ImportError:
ssl = None

if not getattr(ssl, "HAS_SNI", False):
from urllib3.contrib import pyopenssl
pyopenssl.inject_into_urllib3()

# Check cryptography version
from cryptography import __version__ as cryptography_version
_check_cryptography(cryptography_version)
# Check cryptography version
from cryptography import __version__ as cryptography_version
_check_cryptography(cryptography_version)
except ImportError:
pass

Expand Down
4 changes: 2 additions & 2 deletions requests/__version__.py
Expand Up @@ -5,8 +5,8 @@
__title__ = 'requests'
__description__ = 'Python HTTP for Humans.'
__url__ = 'https://requests.readthedocs.io'
__version__ = '2.23.0'
__build__ = 0x022300
__version__ = '2.24.0'
__build__ = 0x022400
__author__ = 'Kenneth Reitz'
__author_email__ = 'me@kennethreitz.org'
__license__ = 'Apache 2.0'
Expand Down
16 changes: 9 additions & 7 deletions requests/models.py
Expand Up @@ -273,7 +273,9 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
"""The fully mutable :class:`PreparedRequest <PreparedRequest>` object,
containing the exact bytes that will be sent to the server.
Generated from either a :class:`Request <Request>` object or manually.
Instances are generated from a :class:`Request <Request>` object, and
should not be instantiated manually; doing so may produce undesirable
effects.
Usage::
Expand Down Expand Up @@ -473,12 +475,12 @@ def prepare_body(self, data, files, json=None):
not isinstance(data, (basestring, list, tuple, Mapping))
])

try:
length = super_len(data)
except (TypeError, AttributeError, UnsupportedOperation):
length = None

if is_stream:
try:
length = super_len(data)
except (TypeError, AttributeError, UnsupportedOperation):
length = None

body = data

if getattr(body, 'tell', None) is not None:
Expand Down Expand Up @@ -916,7 +918,7 @@ def links(self):
return l

def raise_for_status(self):
"""Raises stored :class:`HTTPError`, if one occurred."""
"""Raises :class:`HTTPError`, if one occurred."""

http_error_msg = ''
if isinstance(self.reason, bytes):
Expand Down
10 changes: 6 additions & 4 deletions requests/sessions.py
Expand Up @@ -658,11 +658,13 @@ def send(self, request, **kwargs):

extract_cookies_to_jar(self.cookies, request, r.raw)

# Redirect resolving generator.
gen = self.resolve_redirects(r, request, **kwargs)

# Resolve redirects if allowed.
history = [resp for resp in gen] if allow_redirects else []
if allow_redirects:
# Redirect resolving generator.
gen = self.resolve_redirects(r, request, **kwargs)
history = [resp for resp in gen]
else:
history = []

# Shuffle things around if there's history.
if history:
Expand Down
2 changes: 1 addition & 1 deletion requests/utils.py
Expand Up @@ -212,7 +212,7 @@ def get_netrc_auth(url, raise_errors=False):
if raise_errors:
raise

# AppEngine hackiness.
# App Engine hackiness.
except (ImportError, AttributeError):
pass

Expand Down
6 changes: 4 additions & 2 deletions tests/test_requests.py
Expand Up @@ -776,8 +776,10 @@ def __len__(self):
def test_conflicting_post_params(self, httpbin):
url = httpbin('post')
with open('Pipfile') as f:
pytest.raises(ValueError, "requests.post(url, data='[{\"some\": \"data\"}]', files={'some': f})")
pytest.raises(ValueError, "requests.post(url, data=u('[{\"some\": \"data\"}]'), files={'some': f})")
with pytest.raises(ValueError):
requests.post(url, data='[{"some": "data"}]', files={'some': f})
with pytest.raises(ValueError):
requests.post(url, data=u('[{"some": "data"}]'), files={'some': f})

def test_request_ok_set(self, httpbin):
r = requests.get(httpbin('status', '404'))
Expand Down

0 comments on commit 47cb6fc

Please sign in to comment.