Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: psf/requests
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.25.0
Choose a base ref
...
head repository: psf/requests
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.25.1
Choose a head ref
  • 19 commits
  • 12 files changed
  • 11 contributors

Commits on Sep 23, 2020

  1. Update advanced.rst

    replaced reference to requests-async with httpx the replacement project
    icfly2 authored Sep 23, 2020
    Copy the full SHA
    c3280d7 View commit details

Commits on Nov 16, 2020

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    78fdf4d View commit details
  2. Merge pull request #5659 from nateprewitt/contrib_cleanup

    Remove reference to development philosophy
    sigmavirus24 authored Nov 16, 2020
    Copy the full SHA
    28cc1d2 View commit details

Commits on Nov 17, 2020

  1. Merge pull request #5594 from icfly2/patch-1

    Update advanced.rst
    nateprewitt authored Nov 17, 2020
    Copy the full SHA
    962c898 View commit details

Commits on Nov 18, 2020

  1. Pin GHA to Ubuntu 18.04

    `ubuntu-latest` points to 18.04 and will soon flip to 20.04.
    
    However tests currently fail on 20.04, so let's explicitly pin to 18.04 for now.
    hugovk authored Nov 18, 2020
    Copy the full SHA
    0514dea View commit details
  2. Merge pull request #5663 from hugovk/patch-1

    Pin GHA to Ubuntu 18.04
    nateprewitt authored Nov 18, 2020
    Copy the full SHA
    9ce669e View commit details

Commits on Nov 27, 2020

  1. New helper method set_http_proxy in Session to set proxies in a m…

    …ore user friendly way
    Sylvain MARIE committed Nov 27, 2020
    Copy the full SHA
    4b66260 View commit details
  2. Updated proxies documentation

    Sylvain MARIE committed Nov 27, 2020
    Copy the full SHA
    2fddbe3 View commit details
  3. Revert "New helper method set_http_proxy in Session to set proxie…

    …s in a more user friendly way"
    
    This reverts commit 4b66260
    Sylvain MARIE committed Nov 27, 2020
    Copy the full SHA
    d1ca591 View commit details
  4. Updated proxies documentation

    Sylvain MARIE committed Nov 27, 2020
    Copy the full SHA
    f02a80c View commit details

Commits on Nov 28, 2020

  1. Fix broken link

    sivaraam authored Nov 28, 2020
    Copy the full SHA
    d0359c9 View commit details

Commits on Nov 29, 2020

  1. updated get_encoding_from_headers to return utf-8 if the content ty…

    …pe is set to application/json, following RFC 4627.
    
    fixes #5667
    jjmaldonis committed Nov 29, 2020
    4
    Copy the full SHA
    5855dd7 View commit details
  2. Merge pull request #5673 from jjmaldonis/master

    updated `get_encoding_from_headers` to return utf-8 if the content type is set to application/json
    sigmavirus24 authored Nov 29, 2020
    Copy the full SHA
    589c454 View commit details

Commits on Dec 4, 2020

  1. Merge pull request #5670 from smarie/pr_proxy_conf_helper_and_doc

    Proxy related doc updates
    sigmavirus24 authored Dec 4, 2020
    Copy the full SHA
    5035827 View commit details

Commits on Dec 9, 2020

  1. Update sponsorship link

    PSF relaunched new sponsorship program and the URL has changed.
    ewdurbin authored Dec 9, 2020
    Copy the full SHA
    d3e0f73 View commit details

Commits on Dec 11, 2020

  1. Upgrade to chardet 4.x

    dan-blanchard committed Dec 11, 2020
    Copy the full SHA
    516f84f View commit details

Commits on Dec 14, 2020

  1. Merge pull request #5688 from dan-blanchard/patch-1

    Upgrade to chardet 4.x
    nateprewitt authored Dec 14, 2020
    Copy the full SHA
    b223291 View commit details
  2. Copy the full SHA
    6de4f10 View commit details

Commits on Dec 16, 2020

  1. v2.25.1

    nateprewitt committed Dec 16, 2020
    Copy the full SHA
    c2b307d View commit details
Showing with 76 additions and 24 deletions.
  1. +2 −5 .github/CONTRIBUTING.md
  2. +1 −1 .github/FUNDING.yml
  3. +1 −1 .github/workflows/run-tests.yml
  4. +1 −0 AUTHORS.rst
  5. +11 −0 HISTORY.md
  6. +1 −1 docs/conf.py
  7. +48 −7 docs/user/advanced.rst
  8. +2 −4 requests/__init__.py
  9. +2 −2 requests/__version__.py
  10. +2 −2 requests/sessions.py
  11. +4 −0 requests/utils.py
  12. +1 −1 setup.py
7 changes: 2 additions & 5 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Contribution Guidelines

Before opening any issues or proposing any pull requests, please do the
following:

1. Read our [Contributor's Guide](https://requests.readthedocs.io/en/latest/dev/contributing/).
2. Understand our [development philosophy](https://requests.readthedocs.io/en/latest/dev/philosophy/).
Before opening any issues or proposing any pull requests, please read
our [Contributor's Guide](https://requests.readthedocs.io/en/latest/dev/contributing/).

To get the greatest chance of helpful responses, please also observe the
following additional notes.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
custom: ['https://www.python.org/psf/forms/sponsor-application/']
custom: ['https://www.python.org/psf/sponsorship/']
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ jobs:
fail-fast: false
matrix:
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9]
os: [ubuntu-latest, macOS-latest, windows-latest]
os: [ubuntu-18.04, macOS-latest, windows-latest]
include:
# pypy3 on Mac OS currently fails trying to compile
# brotlipy. Moving pypy3 to only test linux.
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
@@ -190,3 +190,4 @@ Patches and Suggestions
- Antti Kaihola (`@akaihola <https://github.com/akaihola>`_)
- "Dull Bananas" <dull.bananas0@gmail.com> (`@dullbananas <https://github.com/dullbananas>`_)
- Alessio Izzo (`@aless10 <https://github.com/aless10>`_)
- Sylvain Marié (`@smarie <https://github.com/smarie>`_)
11 changes: 11 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -6,6 +6,17 @@ dev

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

2.25.1 (2020-12-16)
-------------------

**Bugfixes**

- Requests now treats `application/json` as `utf8` by default. Resolving
inconsistencies between `r.text` and `r.json` output. (#5673)

**Dependencies**

- Requests now supports chardet v4.x.

2.25.0 (2020-11-11)
------------------
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@

# General information about the project.
project = u"Requests"
copyright = u'MMXVIX. A <a href="http://kennethreitz.com/pages/open-projects.html">Kenneth Reitz</a> Project'
copyright = u'MMXVIX. A <a href="https://kenreitz.org/projects">Kenneth Reitz</a> Project'
author = u"Kenneth Reitz"

# The version info for the project you're documenting, acts as replacement for
55 changes: 48 additions & 7 deletions docs/user/advanced.rst
Original file line number Diff line number Diff line change
@@ -589,10 +589,26 @@ If you need to use a proxy, you can configure individual requests with the

requests.get('http://example.org', proxies=proxies)

You can also configure proxies by setting the environment variables
``HTTP_PROXY`` and ``HTTPS_PROXY``.
Alternatively you can configure it once for an entire
:class:`Session <requests.Session>`::

::
import requests

proxies = {
'http': 'http://10.10.1.10:3128',
'https': 'http://10.10.1.10:1080',
}
session = request.Session()
session.proxies.update(proxies)

session.get('http://example.org')

When the proxies configuration is not overridden in python as shown above,
by default Requests relies on the proxy configuration defined by standard
environment variables ``http_proxy``, ``https_proxy``, ``no_proxy`` and
``curl_ca_bundle``. Uppercase variants of these variables are also supported.
You can therefore set them to configure Requests (only set the ones relevant
to your needs)::

$ export HTTP_PROXY="http://10.10.1.10:3128"
$ export HTTPS_PROXY="http://10.10.1.10:1080"
@@ -601,9 +617,17 @@ You can also configure proxies by setting the environment variables
>>> import requests
>>> requests.get('http://example.org')

To use HTTP Basic Auth with your proxy, use the `http://user:password@host/` syntax::
To use HTTP Basic Auth with your proxy, use the `http://user:password@host/`
syntax in any of the above configuration entries::

proxies = {'http': 'http://user:pass@10.10.1.10:3128/'}
$ export HTTPS_PROXY="http://user:pass@10.10.1.10:1080"

$ python
>>> proxies = {'http': 'http://user:pass@10.10.1.10:3128/'}

.. warning:: Storing sensitive username and password information in an
environment variable or a version-controled file is a security risk and is
highly discouraged.

To give a proxy for a specific scheme and host, use the
`scheme://hostname` form for the key. This will match for
@@ -615,6 +639,23 @@ any request to the given scheme and exact hostname.

Note that proxy URLs must include the scheme.

Finally, note that using a proxy for https connections typically requires your
local machine to trust the proxy's root certificate. By default the list of
certificates trusted by Requests can be found with::

from requests.utils import DEFAULT_CA_BUNDLE_PATH
print(DEFAULT_CA_BUNDLE_PATH)

You override this default certificate bundle by setting the standard
``curl_ca_bundle`` environment variable to another file path::

$ export curl_ca_bundle="/usr/local/myproxy_info/cacert.pem"
$ export https_proxy="http://10.10.1.10:1080"

$ python
>>> import requests
>>> requests.get('https://example.org')

SOCKS
^^^^^

@@ -981,12 +1022,12 @@ response at a time. However, these calls will still block.

If you are concerned about the use of blocking IO, there are lots of projects
out there that combine Requests with one of Python's asynchronicity frameworks.
Some excellent examples are `requests-threads`_, `grequests`_, `requests-futures`_, and `requests-async`_.
Some excellent examples are `requests-threads`_, `grequests`_, `requests-futures`_, and `httpx`_.

.. _`requests-threads`: https://github.com/requests/requests-threads
.. _`grequests`: https://github.com/kennethreitz/grequests
.. _`requests-futures`: https://github.com/ross/requests-futures
.. _`requests-async`: https://github.com/encode/requests-async
.. _`httpx`: https://github.com/encode/httpx

Header Ordering
---------------
6 changes: 2 additions & 4 deletions requests/__init__.py
Original file line number Diff line number Diff line change
@@ -65,10 +65,8 @@ def check_compatibility(urllib3_version, chardet_version):
# Check chardet for compatibility.
major, minor, patch = chardet_version.split('.')[:3]
major, minor, patch = int(major), int(minor), int(patch)
# chardet >= 3.0.2, < 3.1.0
assert major == 3
assert minor < 1
assert patch >= 2
# chardet >= 3.0.2, < 5.0.0
assert (3, 0, 2) <= (major, minor, patch) < (5, 0, 0)


def _check_cryptography(cryptography_version):
4 changes: 2 additions & 2 deletions requests/__version__.py
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@
__title__ = 'requests'
__description__ = 'Python HTTP for Humans.'
__url__ = 'https://requests.readthedocs.io'
__version__ = '2.25.0'
__build__ = 0x022500
__version__ = '2.25.1'
__build__ = 0x022501
__author__ = 'Kenneth Reitz'
__author_email__ = 'me@kennethreitz.org'
__license__ = 'Apache 2.0'
4 changes: 2 additions & 2 deletions requests/sessions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-

"""
requests.session
~~~~~~~~~~~~~~~~
requests.sessions
~~~~~~~~~~~~~~~~~
This module provides a Session object to manage and persist settings across
requests (cookies, auth, proxies).
4 changes: 4 additions & 0 deletions requests/utils.py
Original file line number Diff line number Diff line change
@@ -503,6 +503,10 @@ def get_encoding_from_headers(headers):
if 'text' in content_type:
return 'ISO-8859-1'

if 'application/json' in content_type:
# Assume UTF-8 based on RFC 4627: https://www.ietf.org/rfc/rfc4627.txt since the charset was unset
return 'utf-8'


def stream_decode_response_unicode(iterator, r):
"""Stream decodes a iterator."""
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ def run_tests(self):
packages = ['requests']

requires = [
'chardet>=3.0.2,<4',
'chardet>=3.0.2,<5',
'idna>=2.5,<3',
'urllib3>=1.21.1,<1.27',
'certifi>=2017.4.17'