Compare commits
61 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
282b01a7c9 | ||
|
|
e1539ac8ff | ||
|
|
8c2a36140b | ||
|
|
60b9fb17af | ||
|
|
0aee483497 | ||
|
|
bf53ace6f8 | ||
|
|
4c3d307eb9 | ||
|
|
380d130245 | ||
|
|
c3367d1854 | ||
|
|
a7239aab84 | ||
|
|
dfd667df96 | ||
|
|
f41560c5d4 | ||
|
|
ce64cce14e | ||
|
|
60041f5169 | ||
|
|
14d6fa1472 | ||
|
|
64efd9cfe0 | ||
|
|
1001bc671a | ||
|
|
733ff4b8a4 | ||
|
|
296c215762 | ||
|
|
cc7b3ee7ed | ||
|
|
e038aad3cc | ||
|
|
4f8f4b5fb3 | ||
|
|
ce882a2eae | ||
|
|
f581dc95a9 | ||
|
|
7abfd92aea | ||
|
|
9fbfd22f6b | ||
|
|
e634ab73b2 | ||
|
|
3e32356716 | ||
|
|
539302a17d | ||
|
|
037108178c | ||
|
|
f3d310b299 | ||
|
|
874bca97cb | ||
|
|
dbb67a1310 | ||
|
|
a9470fe31f | ||
|
|
0ba21a79c4 | ||
|
|
66293b830a | ||
|
|
6fb9b1ce53 | ||
|
|
2772413f3d | ||
|
|
ba63e50ecd | ||
|
|
2c71f2d520 | ||
|
|
fb3f2a030f | ||
|
|
00c6ad58b7 | ||
|
|
af66521381 | ||
|
|
a8bfa82801 | ||
|
|
6ab6a18ab2 | ||
|
|
570c4c83a5 | ||
|
|
e2142a1e54 | ||
|
|
52a2efa2ae | ||
|
|
f88e573c18 | ||
|
|
da29295369 | ||
|
|
dbdbffd7f5 | ||
|
|
a3f2972c4f | ||
|
|
1553770014 | ||
|
|
37ef88885c | ||
|
|
2cb07872fe | ||
|
|
2667c772b9 | ||
|
|
0280a18b53 | ||
|
|
f4b90827b0 | ||
|
|
e4693eba4f | ||
|
|
2e496c3e1d | ||
|
|
f3f4c3e20a |
@@ -14,6 +14,8 @@ python:
|
||||
install: "make"
|
||||
# command to run tests
|
||||
script:
|
||||
- |
|
||||
if [[ "$TRAVIS_PYTHON_VERSION" != "2.6" ]] ; then make test-readme; fi
|
||||
- make coverage
|
||||
after_success:
|
||||
- pipenv run codecov
|
||||
|
||||
3
CODE_OF_CONDUCT.md
Normal file
3
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Be cordial or be on your way.
|
||||
|
||||
https://www.kennethreitz.org/essays/be-cordial-or-be-on-your-way
|
||||
28
HISTORY.rst
28
HISTORY.rst
@@ -3,6 +3,32 @@
|
||||
Release History
|
||||
---------------
|
||||
|
||||
2.15.1 (2017-05-26)
|
||||
+++++++++++++++++++
|
||||
|
||||
Everyone makes mistakes.
|
||||
|
||||
2.15.0 (2017-05-26)
|
||||
+++++++++++++++++++
|
||||
|
||||
**Improvements**
|
||||
|
||||
- Introduction of the ``Response.next`` property, for getting the next
|
||||
``PreparedResponse`` from a redirect chain (when ``allow_redirects=False``).
|
||||
- Internal refactoring of ``__version__`` module.
|
||||
|
||||
**Bugfixes**
|
||||
|
||||
- Restored once-optional parameter for ``requests.utils.get_environ_proxies()``.
|
||||
|
||||
2.14.2 (2017-05-10)
|
||||
+++++++++++++++++++
|
||||
|
||||
**Bugfixes**
|
||||
|
||||
- Changed a less-than to an equal-to and an or in the dependency markers to
|
||||
widen compatibility with older setuptools releases.
|
||||
|
||||
2.14.1 (2017-05-09)
|
||||
+++++++++++++++++++
|
||||
|
||||
@@ -39,7 +65,7 @@ Release History
|
||||
**Bugfixes**
|
||||
|
||||
- Much improved handling of non-ASCII ``Location`` header values in redirects.
|
||||
Fewer ``UnicodeDecodeError``s are encountered on Python 2, and Python 3 now
|
||||
Fewer ``UnicodeDecodeErrors`` are encountered on Python 2, and Python 3 now
|
||||
correctly understands that Latin-1 is unlikely to be the correct encoding.
|
||||
- If an attempt to ``seek`` file to find out its length fails, we now
|
||||
appropriately handle that by aborting our content-length calculations.
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
include README.rst LICENSE NOTICE HISTORY.rst test_requests.py requests/cacert.pem
|
||||
include README.rst LICENSE NOTICE HISTORY.rst pytest.ini requests/cacert.pem
|
||||
recursive-include tests *.py
|
||||
|
||||
7
Makefile
7
Makefile
@@ -2,7 +2,6 @@
|
||||
|
||||
init:
|
||||
pip install pipenv
|
||||
pipenv lock
|
||||
pipenv install --dev
|
||||
pipenv run pip install -e .[socks]
|
||||
|
||||
@@ -11,6 +10,9 @@ test:
|
||||
# the -k flag, like "py.test -k test_path_is_not_double_encoded"
|
||||
pipenv run py.test tests
|
||||
|
||||
test-readme:
|
||||
pipenv run python setup.py check -r -s
|
||||
|
||||
coverage:
|
||||
pipenv run py.test --cov-config .coveragerc --verbose --cov-report term --cov-report xml --cov=requests tests
|
||||
|
||||
@@ -48,8 +50,7 @@ idna:
|
||||
|
||||
publish:
|
||||
pip install 'twine>=1.5.0'
|
||||
python setup.py sdist
|
||||
python setup.py bdist_wheel --universal
|
||||
python setup.py sdist bdist_wheel
|
||||
twine upload dist/*
|
||||
rm -fr build dist .egg requests.egg-info
|
||||
|
||||
|
||||
5
Pipfile
5
Pipfile
@@ -6,8 +6,9 @@ verify_ssl = true
|
||||
pytest = ">=2.8.0"
|
||||
codecov = "*"
|
||||
pytest-httpbin = "==0.0.7"
|
||||
sphinx = "*"
|
||||
pytest-mock = "*"
|
||||
pytest-cov = "*"
|
||||
pysocks = "*"
|
||||
alabaster = "*"
|
||||
readme_renderer = "*"
|
||||
Sphinx = "<=1.5.5"
|
||||
PySocks = "*"
|
||||
251
Pipfile.lock
generated
251
Pipfile.lock
generated
@@ -1,153 +1,116 @@
|
||||
{
|
||||
"default": {},
|
||||
"develop": {
|
||||
"snowballstemmer": {
|
||||
"version": "==1.2.1",
|
||||
"hash": "sha256:9f3bcd3c401c3e862ec0ebe6d2c069ebc012ce142cce209c098ccb5b09136e89"
|
||||
},
|
||||
"Werkzeug": {
|
||||
"version": "==0.11.15",
|
||||
"hash": "sha256:c6f6f89124df0514d886782c658c3e12f2caaa94da34cee3fd82eebf4ebf052b"
|
||||
},
|
||||
"six": {
|
||||
"version": "==1.10.0",
|
||||
"hash": "sha256:0ff78c403d9bccf5a425a6d31a12aa6b47f1c21ca4dc2573a7e2f32a97335eb1"
|
||||
},
|
||||
"funcsigs": {
|
||||
"version": "==1.0.2",
|
||||
"hash": "sha256:330cc27ccbf7f1e992e69fef78261dc7c6569012cf397db8d3de0234e6c937ca"
|
||||
},
|
||||
"coverage": {
|
||||
"version": "==4.3.4",
|
||||
"hash": "sha256:36407249a0b6669c6ad4425b0f29685579df745480c03afa70f101f09f4eead3"
|
||||
},
|
||||
"Flask": {
|
||||
"version": "==0.12",
|
||||
"hash": "sha256:7f03bb2c255452444f7265eddb51601806e5447b6f8a2d50bbc77a654a14c118"
|
||||
},
|
||||
"alabaster": {
|
||||
"version": "==0.7.9",
|
||||
"hash": "sha256:d3e64a74919373d6d4d1d36bd717206584cb64cbb0532dfce3bc2081cba6817b"
|
||||
},
|
||||
"pytest-mock": {
|
||||
"version": "==1.5.0",
|
||||
"hash": "sha256:8e0fd43280c717f36920b60356bd713291b81a61704c94bc13aae9a12ef7fbd8"
|
||||
},
|
||||
"packaging": {
|
||||
"version": "==16.8",
|
||||
"hash": "sha256:99276dc6e3a7851f32027a68f1095cd3f77c148091b092ea867a351811cfe388"
|
||||
},
|
||||
"MarkupSafe": {
|
||||
"version": "==0.23",
|
||||
"hash": "sha256:a4ec1aff59b95a14b45eb2e23761a0179e98319da5a7eb76b56ea8cdc7b871c3"
|
||||
},
|
||||
"pytz": {
|
||||
"version": "==2016.10",
|
||||
"hash": "sha256:a1ea35e87a63c7825846d5b5c81d23d668e8a102d3b1b465ce95afe1b3a2e065"
|
||||
},
|
||||
"codecov": {
|
||||
"version": "==2.0.5",
|
||||
"hash": "sha256:9fb0cd4a43fe538b4ea229607d0a7d65b00f9bfb37bb6af60a17f4ac33707334"
|
||||
},
|
||||
"pytest-httpbin": {
|
||||
"version": "==0.2.3",
|
||||
"hash": "sha256:c5b698dfa474ffc9caebcb35e34346b753eb226aea5c2e1b69fefedbcf161bf8"
|
||||
},
|
||||
"httpbin": {
|
||||
"version": "==0.5.0",
|
||||
"hash": "sha256:710069973216d4bbf9ab6757f1e9a1f3be05832ce77da023adce0a98dfeecfee"
|
||||
},
|
||||
"pyparsing": {
|
||||
"version": "==2.1.10",
|
||||
"hash": "sha256:67101d7acee692962f33dd30b5dce079ff532dd9aa99ff48d52a3dad51d2fe84"
|
||||
},
|
||||
"click": {
|
||||
"version": "==6.7",
|
||||
"hash": "sha256:29f99fc6125fbc931b758dc053b3114e55c77a6e4c6c3a2674a2dc986016381d"
|
||||
},
|
||||
"appdirs": {
|
||||
"version": "==1.4.0",
|
||||
"hash": "sha256:85e58578db8f29538f3109c11250c2a5514a2fcdc9890d9b2fe777eb55517736"
|
||||
},
|
||||
"imagesize": {
|
||||
"version": "==0.7.1",
|
||||
"hash": "sha256:6ebdc9e0ad188f9d1b2cdd9bc59cbe42bf931875e829e7a595e6b3abdc05cdfb"
|
||||
},
|
||||
"argparse": {
|
||||
"version": "==1.4.0",
|
||||
"hash": "sha256:c31647edb69fd3d465a847ea3157d37bed1f95f19760b11a47aa91c04b666314"
|
||||
},
|
||||
"sphinx": {
|
||||
"version": "==1.5.2",
|
||||
"hash": "sha256:57c8636e1d23f6c01fb19911a8f255f1b4934ba69feb55bd4dd0f097ebb04f05"
|
||||
},
|
||||
"pbr": {
|
||||
"version": "==1.10.0",
|
||||
"hash": "sha256:f5cf7265a80636ecff66806d13494cbf9d77a3758a65fd8b4d4d4bee81b0c375"
|
||||
},
|
||||
"babel": {
|
||||
"version": "==2.3.4",
|
||||
"hash": "sha256:3318ed2960240d61cbc6558858ee00c10eed77a6508c4d1ed8e6f7f48399c975"
|
||||
},
|
||||
"py": {
|
||||
"version": "==1.4.32",
|
||||
"hash": "sha256:2d4bba2e25fff58140e6bdce1e485e89bb59776adbe01d490baa6b1f37a3dd6b"
|
||||
},
|
||||
"pytest-cov": {
|
||||
"version": "==2.4.0",
|
||||
"hash": "sha256:10e37e876f49ddec80d6c83a54b657157f1387ebc0f7755285f8c156130014a1"
|
||||
},
|
||||
"pytest": {
|
||||
"version": "==3.0.6",
|
||||
"hash": "sha256:da0ab50c7eec0683bc24f1c1137db1f4111752054ecdad63125e7ec71316b813"
|
||||
},
|
||||
"docutils": {
|
||||
"version": "==0.13.1",
|
||||
"hash": "sha256:de454f1015958450b72641165c08afe7023cd7e3944396448f2fb1b0ccba9d77"
|
||||
},
|
||||
"Pygments": {
|
||||
"version": "==2.2.0",
|
||||
"hash": "sha256:78f3f434bcc5d6ee09020f92ba487f95ba50f1e3ef83ae96b9d5ffa1bab25c5d"
|
||||
},
|
||||
"Jinja2": {
|
||||
"version": "==2.9.5",
|
||||
"hash": "sha256:a7b7438120dbe76a8e735ef7eba6048eaf4e0b7dbc530e100812f8ec462a4d50"
|
||||
},
|
||||
"decorator": {
|
||||
"version": "==4.0.11",
|
||||
"hash": "sha256:73cbaadb8bc4e3c65fe1100773d56331a2d756cc0f5c7b9d8d5d5223fe04f600"
|
||||
},
|
||||
"setuptools": {
|
||||
"version": "==34.1.0",
|
||||
"hash": "sha256:edd9d39782fe38b9c533002b2e6fdf06498793cbd29266accdcc519431d4b7ba"
|
||||
},
|
||||
"requests": {
|
||||
"version": "==2.13.0",
|
||||
"hash": "sha256:1a720e8862a41aa22e339373b526f508ef0c8988baf48b84d3fc891a8e237efb"
|
||||
},
|
||||
"itsdangerous": {
|
||||
"version": "==0.24",
|
||||
"hash": "sha256:cbb3fcf8d3e33df861709ecaf89d9e6629cff0a217bc2848f1b41cd30d360519"
|
||||
},
|
||||
"pysocks": {
|
||||
"version": "==1.6.6",
|
||||
"hash": "sha256:02419a225ff5dcfc3c9695ef8fc9b4d8cc99658e650c6d4718d4c8f451e63f41"
|
||||
},
|
||||
"mock": {
|
||||
"version": "==2.0.0",
|
||||
"hash": "sha256:5ce3c71c5545b472da17b72268978914d0252980348636840bd34a00b5cc96c1"
|
||||
}
|
||||
},
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "a26ef57f42fa3da7d70d1c1decb4e6445a6ff66e47c9094ddc9ab8e1f4c0a5b6"
|
||||
},
|
||||
"requires": {},
|
||||
"sources": [
|
||||
{
|
||||
"url": "https://pypi.python.org/simple",
|
||||
"verify_ssl": true
|
||||
}
|
||||
],
|
||||
"requires": {},
|
||||
"hash": {
|
||||
"sha256": "0b4728fe74b683054ddde5b9dba7dd674ce17b6726764407a9779b4fdd0afd47"
|
||||
]
|
||||
},
|
||||
"default": {},
|
||||
"develop": {
|
||||
"alabaster": {
|
||||
"version": "==0.7.10"
|
||||
},
|
||||
"appdirs": {
|
||||
"version": "==1.4.3"
|
||||
},
|
||||
"babel": {
|
||||
"version": "==2.4.0"
|
||||
},
|
||||
"click": {
|
||||
"version": "==6.7"
|
||||
},
|
||||
"codecov": {
|
||||
"version": "==2.0.9"
|
||||
},
|
||||
"coverage": {
|
||||
"version": "==4.4.1"
|
||||
},
|
||||
"decorator": {
|
||||
"version": "==4.0.11"
|
||||
},
|
||||
"docutils": {
|
||||
"version": "==0.13.1"
|
||||
},
|
||||
"flask": {
|
||||
"version": "==0.12.2"
|
||||
},
|
||||
"funcsigs": {
|
||||
"version": "==1.0.2"
|
||||
},
|
||||
"httpbin": {
|
||||
"version": "==0.5.0"
|
||||
},
|
||||
"imagesize": {
|
||||
"version": "==0.7.1"
|
||||
},
|
||||
"itsdangerous": {
|
||||
"version": "==0.24"
|
||||
},
|
||||
"jinja2": {
|
||||
"version": "==2.9.6"
|
||||
},
|
||||
"markupsafe": {
|
||||
"version": "==1.0"
|
||||
},
|
||||
"mock": {
|
||||
"version": "==2.0.0"
|
||||
},
|
||||
"packaging": {
|
||||
"version": "==16.8"
|
||||
},
|
||||
"pbr": {
|
||||
"version": "==3.0.0"
|
||||
},
|
||||
"py": {
|
||||
"version": "==1.4.33"
|
||||
},
|
||||
"pygments": {
|
||||
"version": "==2.2.0"
|
||||
},
|
||||
"pyparsing": {
|
||||
"version": "==2.2.0"
|
||||
},
|
||||
"pysocks": {
|
||||
"version": "==1.6.7"
|
||||
},
|
||||
"pytest": {
|
||||
"version": "==3.0.7"
|
||||
},
|
||||
"pytest-cov": {
|
||||
"version": "==2.5.1"
|
||||
},
|
||||
"pytest-httpbin": {
|
||||
"version": "==0.0.7"
|
||||
},
|
||||
"pytest-mock": {
|
||||
"version": "==1.6.0"
|
||||
},
|
||||
"pytz": {
|
||||
"version": "==2017.2"
|
||||
},
|
||||
"requests": {
|
||||
"version": "==2.14.2"
|
||||
},
|
||||
"setuptools": {
|
||||
"version": "==35.0.2"
|
||||
},
|
||||
"six": {
|
||||
"version": "==1.10.0"
|
||||
},
|
||||
"snowballstemmer": {
|
||||
"version": "==1.2.1"
|
||||
},
|
||||
"sphinx": {
|
||||
"version": "==1.5.5"
|
||||
},
|
||||
"werkzeug": {
|
||||
"version": "==0.12.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,6 @@ Requests is ready for today's web.
|
||||
- Streaming Downloads
|
||||
- ``.netrc`` Support
|
||||
- Chunked Requests
|
||||
- Thread-safety
|
||||
|
||||
Requests officially supports Python 2.6–2.7 & 3.3–3.7, and runs great on PyPy.
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ sys.path.insert(0, os.path.abspath('..'))
|
||||
sys.path.insert(0, os.path.abspath('_themes'))
|
||||
|
||||
import requests
|
||||
from requests import __version__
|
||||
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
@@ -67,9 +66,9 @@ author = u'Kenneth Reitz'
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = __version__
|
||||
version = requests.__version__
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = __version__
|
||||
release = requests.__version__
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
||||
@@ -63,9 +63,9 @@ which is embedded within Requests.
|
||||
User Testimonials
|
||||
-----------------
|
||||
|
||||
Reddit, The NSA, Her Majesty's Government, Amazon, Google, Twilio, Runscope, Mozilla, Heroku,
|
||||
Twitter, Spotify, Microsoft, Amazon, Lyft, BuzzFeed, Reddit, The NSA, Her Majesty's Government, Google, Twilio, Runscope, Mozilla, Heroku,
|
||||
PayPal, NPR, Obama for America, Transifex, Native Instruments, The Washington
|
||||
Post, Twitter, SoundCloud, Kippt, Sony, and Federal U.S.
|
||||
Post, SoundCloud, Kippt, Sony, and Federal U.S.
|
||||
Institutions that prefer to be unnamed claim to use Requests internally.
|
||||
|
||||
**Armin Ronacher**—
|
||||
@@ -73,12 +73,12 @@ Institutions that prefer to be unnamed claim to use Requests internally.
|
||||
right level of abstraction.*
|
||||
|
||||
**Matt DeBoard**—
|
||||
*I'm going to get `@kennethreitz <https://twitter.com/kennethreitz>`_'s Python requests module tattooed
|
||||
*I'm going to get Kenneth Reitz's Python requests module tattooed
|
||||
on my body, somehow. The whole thing.*
|
||||
|
||||
**Daniel Greenfeld**—
|
||||
*Nuked a 1200 LOC spaghetti code library with 10 lines of code thanks to
|
||||
`@kennethreitz <https://twitter.com/kennethreitz>`_'s request library. Today has been AWESOME.*
|
||||
Kenneth Reitz's request library. Today has been AWESOME.*
|
||||
|
||||
**Kenny Meyers**—
|
||||
*Python HTTP: When in doubt, or when not in doubt, use Requests. Beautiful,
|
||||
@@ -107,7 +107,6 @@ Requests is ready for today's web.
|
||||
- Connection Timeouts
|
||||
- Chunked Requests
|
||||
- ``.netrc`` Support
|
||||
- Thread-safety
|
||||
|
||||
Requests officially supports Python 2.6–2.7 & 3.3–3.7, and runs great on PyPy.
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ Requests can also ignore verifying the SSL certificate if you set ``verify`` to
|
||||
|
||||
By default, ``verify`` is set to True. Option ``verify`` only applies to host certs.
|
||||
|
||||
Client side certificates
|
||||
Client Side Certificates
|
||||
------------------------
|
||||
|
||||
You can also specify a local cert to use as client side certificate, as a single
|
||||
|
||||
2
pytest.ini
Normal file
2
pytest.ini
Normal file
@@ -0,0 +1,2 @@
|
||||
[pytest]
|
||||
addopts = -p no:warnings
|
||||
@@ -6,7 +6,7 @@
|
||||
# /
|
||||
|
||||
"""
|
||||
Requests HTTP library
|
||||
Requests HTTP Library
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Requests is an HTTP library, written in Python, for human beings. Basic GET
|
||||
@@ -36,16 +36,13 @@ usage:
|
||||
The other HTTP methods are supported - see `requests.api`. Full documentation
|
||||
is at <http://python-requests.org>.
|
||||
|
||||
:copyright: (c) 2016 by Kenneth Reitz.
|
||||
:copyright: (c) 2017 by Kenneth Reitz.
|
||||
:license: Apache 2.0, see LICENSE for more details.
|
||||
"""
|
||||
|
||||
__title__ = 'requests'
|
||||
__version__ = '2.14.1'
|
||||
__build__ = 0x021401
|
||||
__author__ = 'Kenneth Reitz'
|
||||
__license__ = 'Apache 2.0'
|
||||
__copyright__ = 'Copyright 2016 Kenneth Reitz'
|
||||
from .__version__ import __title__, __description__, __url__, __version__
|
||||
from .__version__ import __build__, __author__, __author_email__, __license__
|
||||
from .__version__ import __copyright__, __cake__
|
||||
|
||||
# Attempt to enable urllib3's SNI support, if possible
|
||||
try:
|
||||
|
||||
16
requests/__version__.py
Normal file
16
requests/__version__.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# .-. .-. .-. . . .-. .-. .-. .-.
|
||||
# |( |- |.| | | |- `-. | `-.
|
||||
# ' ' `-' `-`.`-' `-' `-' ' `-'
|
||||
|
||||
__title__ = 'requests'
|
||||
__description__ = 'Python HTTP for Humans.'
|
||||
__url__ = 'http://python-requests.org'
|
||||
__version__ = '2.15.1'
|
||||
__build__ = 0x021501
|
||||
__author__ = 'Kenneth Reitz'
|
||||
__author_email__ = 'me@kennethreitz.org'
|
||||
__license__ = 'Apache 2.0'
|
||||
__copyright__ = 'Copyright 2017 Kenneth Reitz'
|
||||
__cake__ = u'✨ 🍰 ✨'
|
||||
@@ -241,6 +241,7 @@ class HTTPAdapter(BaseAdapter):
|
||||
conn.key_file = cert[1]
|
||||
else:
|
||||
conn.cert_file = cert
|
||||
conn.key_file = None
|
||||
if conn.cert_file and not os.path.exists(conn.cert_file):
|
||||
raise IOError("Could not find the TLS certificate file, "
|
||||
"invalid path: {0}".format(conn.cert_file))
|
||||
|
||||
@@ -593,6 +593,7 @@ class Response(object):
|
||||
|
||||
self._content = False
|
||||
self._content_consumed = False
|
||||
self._next = None
|
||||
|
||||
#: Integer Code of responded HTTP Status, e.g. 404 or 200.
|
||||
self.status_code = None
|
||||
@@ -706,12 +707,17 @@ class Response(object):
|
||||
|
||||
@property
|
||||
def is_permanent_redirect(self):
|
||||
"""True if this Response one of the permanent versions of redirect"""
|
||||
"""True if this Response one of the permanent versions of redirect."""
|
||||
return ('location' in self.headers and self.status_code in (codes.moved_permanently, codes.permanent_redirect))
|
||||
|
||||
@property
|
||||
def next(self):
|
||||
"""Returns a PreparedRequest for the next request in a redirect chain, if there is one."""
|
||||
return self._next
|
||||
|
||||
@property
|
||||
def apparent_encoding(self):
|
||||
"""The apparent encoding, provided by the chardet library"""
|
||||
"""The apparent encoding, provided by the chardet library."""
|
||||
return chardet.detect(self.content)['encoding']
|
||||
|
||||
def iter_content(self, chunk_size=1, decode_unicode=False):
|
||||
|
||||
@@ -114,8 +114,8 @@ class SessionRedirectMixin(object):
|
||||
return None
|
||||
|
||||
def resolve_redirects(self, resp, req, stream=False, timeout=None,
|
||||
verify=True, cert=None, proxies=None, **adapter_kwargs):
|
||||
"""Receives a Response. Returns a generator of Responses."""
|
||||
verify=True, cert=None, proxies=None, yield_requests=False, **adapter_kwargs):
|
||||
"""Receives a Response. Returns a generator of Responses or Requests."""
|
||||
|
||||
hist = [] # keep track of history
|
||||
|
||||
@@ -203,22 +203,26 @@ class SessionRedirectMixin(object):
|
||||
# Override the original request.
|
||||
req = prepared_request
|
||||
|
||||
resp = self.send(
|
||||
req,
|
||||
stream=stream,
|
||||
timeout=timeout,
|
||||
verify=verify,
|
||||
cert=cert,
|
||||
proxies=proxies,
|
||||
allow_redirects=False,
|
||||
**adapter_kwargs
|
||||
)
|
||||
if yield_requests:
|
||||
yield req
|
||||
else:
|
||||
|
||||
extract_cookies_to_jar(self.cookies, prepared_request, resp.raw)
|
||||
resp = self.send(
|
||||
req,
|
||||
stream=stream,
|
||||
timeout=timeout,
|
||||
verify=verify,
|
||||
cert=cert,
|
||||
proxies=proxies,
|
||||
allow_redirects=False,
|
||||
**adapter_kwargs
|
||||
)
|
||||
|
||||
# extract redirect url, if any, for the next loop
|
||||
url = self.get_redirect_target(resp)
|
||||
yield resp
|
||||
extract_cookies_to_jar(self.cookies, prepared_request, resp.raw)
|
||||
|
||||
# extract redirect url, if any, for the next loop
|
||||
url = self.get_redirect_target(resp)
|
||||
yield resp
|
||||
|
||||
def rebuild_auth(self, prepared_request, response):
|
||||
"""When being redirected we may want to strip authentication from the
|
||||
@@ -597,8 +601,7 @@ class Session(SessionRedirectMixin):
|
||||
return self.request('DELETE', url, **kwargs)
|
||||
|
||||
def send(self, request, **kwargs):
|
||||
"""
|
||||
Send a given PreparedRequest.
|
||||
"""Send a given PreparedRequest.
|
||||
|
||||
:rtype: requests.Response
|
||||
"""
|
||||
@@ -668,6 +671,13 @@ class Session(SessionRedirectMixin):
|
||||
r = history.pop()
|
||||
r.history = history
|
||||
|
||||
# If redirects aren't being followed, store the response on the Request for Response.next().
|
||||
if not allow_redirects:
|
||||
try:
|
||||
r._next = next(self.resolve_redirects(r, request, yield_requests=True, **kwargs))
|
||||
except StopIteration:
|
||||
pass
|
||||
|
||||
if not stream:
|
||||
r.content
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import socket
|
||||
import struct
|
||||
import warnings
|
||||
|
||||
from . import __version__
|
||||
from .__version__ import __version__
|
||||
from . import certs
|
||||
# to_native_string is unused here, but imported here for backwards compatibility
|
||||
from ._internal_utils import to_native_string
|
||||
@@ -684,7 +684,7 @@ def should_bypass_proxies(url, no_proxy):
|
||||
return False
|
||||
|
||||
|
||||
def get_environ_proxies(url, no_proxy):
|
||||
def get_environ_proxies(url, no_proxy=None):
|
||||
"""
|
||||
Return a dict of environment proxies.
|
||||
|
||||
|
||||
31
setup.py
31
setup.py
@@ -9,6 +9,7 @@ from codecs import open
|
||||
from setuptools import setup
|
||||
from setuptools.command.test import test as TestCommand
|
||||
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
class PyTest(TestCommand):
|
||||
user_options = [('pytest-args=', 'a', "Arguments to pass into py.test")]
|
||||
@@ -28,9 +29,10 @@ class PyTest(TestCommand):
|
||||
errno = pytest.main(self.pytest_args)
|
||||
sys.exit(errno)
|
||||
|
||||
|
||||
# 'setup.py publish' shortcut.
|
||||
if sys.argv[-1] == 'publish':
|
||||
os.system('python setup.py sdist upload')
|
||||
os.system('python setup.py sdist bdist_wheel')
|
||||
os.system('twine upload dist/*')
|
||||
sys.exit()
|
||||
|
||||
packages = [
|
||||
@@ -51,12 +53,9 @@ packages = [
|
||||
requires = []
|
||||
test_requirements = ['pytest>=2.8.0', 'pytest-httpbin==0.0.7', 'pytest-cov', 'pytest-mock']
|
||||
|
||||
with open('requests/__init__.py', 'r') as fd:
|
||||
version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
|
||||
fd.read(), re.MULTILINE).group(1)
|
||||
|
||||
if not version:
|
||||
raise RuntimeError('Cannot find version information')
|
||||
about = {}
|
||||
with open(os.path.join(here, 'requests', '__version__.py')) as f:
|
||||
exec(f.read(), about)
|
||||
|
||||
with open('README.rst', 'r', 'utf-8') as f:
|
||||
readme = f.read()
|
||||
@@ -64,19 +63,19 @@ with open('HISTORY.rst', 'r', 'utf-8') as f:
|
||||
history = f.read()
|
||||
|
||||
setup(
|
||||
name='requests',
|
||||
version=version,
|
||||
description='Python HTTP for Humans.',
|
||||
name=about['__title__'],
|
||||
version=about['__version__'],
|
||||
description=about['__description__'],
|
||||
long_description=readme + '\n\n' + history,
|
||||
author='Kenneth Reitz',
|
||||
author_email='me@kennethreitz.com',
|
||||
url='http://python-requests.org',
|
||||
author=about['__author__'],
|
||||
author_email=about['__author_email__'],
|
||||
url=about['__url__'],
|
||||
packages=packages,
|
||||
package_data={'': ['LICENSE', 'NOTICE'], 'requests': ['*.pem']},
|
||||
package_dir={'requests': 'requests'},
|
||||
include_package_data=True,
|
||||
install_requires=requires,
|
||||
license='Apache 2.0',
|
||||
license=about['__license__'],
|
||||
zip_safe=False,
|
||||
classifiers=(
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
@@ -99,7 +98,7 @@ setup(
|
||||
extras_require={
|
||||
'security': ['pyOpenSSL>=0.14', 'cryptography>=1.3.4', 'idna>=2.0.0'],
|
||||
'socks': ['PySocks>=1.5.6, !=1.5.7'],
|
||||
'socks:sys_platform == "win32" and python_version<"3.3"': ['win_inet_pton'],
|
||||
'socks:sys_platform == "win32" and (python_version == "2.7" or python_version == "2.6")': ['win_inet_pton'],
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -786,6 +786,10 @@ class TestRequests:
|
||||
requests.get(httpbin_secure(), cert=('.', INVALID_PATH))
|
||||
assert str(e.value) == 'Could not find the TLS key file, invalid path: {0}'.format(INVALID_PATH)
|
||||
|
||||
def test_http_with_certificate(self, httpbin):
|
||||
r = requests.get(httpbin(), cert='.')
|
||||
assert r.status_code == 200
|
||||
|
||||
def test_https_warnings(self, httpbin_secure, httpbin_ca_bundle):
|
||||
"""warnings are emitted with requests.get"""
|
||||
if HAS_MODERN_SSL or HAS_PYOPENSSL:
|
||||
|
||||
Reference in New Issue
Block a user