Compare commits

...

61 Commits

Author SHA1 Message Date
Kenneth Reitz
282b01a7c9 new release 2017-05-26 22:13:29 -04:00
Kenneth Reitz
e1539ac8ff everyone makes mistakes :P 2017-05-26 22:12:38 -04:00
Kenneth Reitz
8c2a36140b fix for python 3 2017-05-26 22:08:46 -04:00
Kenneth Reitz
60b9fb17af too much 2017-05-26 21:48:35 -04:00
Kenneth Reitz
0aee483497 fix setup.py 2017-05-26 21:43:03 -04:00
Kenneth Reitz
bf53ace6f8 v2.15.0 2017-05-26 21:38:23 -04:00
Kenneth Reitz
4c3d307eb9 Merge pull request #4052 from hile/master
Fix regression in API caused by commit 85400d8d6751071ef78f042d1efa72…
2017-05-26 18:34:30 -07:00
Kenneth Reitz
380d130245 Merge pull request #4066 from kennethreitz/next
API improvements
2017-05-26 18:33:28 -07:00
Kenneth Reitz
c3367d1854 remove Request.send(session) 2017-05-26 21:28:52 -04:00
Kenneth Reitz
a7239aab84 feedback from @sigmavirus42 2017-05-26 21:23:55 -04:00
Kenneth Reitz
dfd667df96 who wrote this shit 2017-05-26 21:17:13 -04:00
Kenneth Reitz
f41560c5d4 fix the tests 2017-05-26 21:15:58 -04:00
Kenneth Reitz
ce64cce14e API improvements 2017-05-26 21:07:37 -04:00
Kenneth Reitz
60041f5169 Create CODE_OF_CONDUCT.md 2017-05-26 20:32:06 -04:00
Kenneth Reitz
14d6fa1472 __version__.py 2017-05-25 20:07:38 -04:00
Kenneth Reitz
64efd9cfe0 yay i knew i wasn't crazy 2017-05-25 20:07:23 -04:00
Kenneth Reitz
1001bc671a fix imports 2017-05-25 19:58:44 -04:00
Kenneth Reitz
733ff4b8a4 Merge branch 'master' of github.com:kennethreitz/requests 2017-05-25 19:52:31 -04:00
Kenneth Reitz
296c215762 __version__ 2017-05-25 19:52:17 -04:00
Kenneth Reitz
cc7b3ee7ed Merge pull request #4064 from sigmavirus24/fix-rtfd
Avoid breaking people using requests.__version__
2017-05-25 16:46:08 -07:00
Ian Cordasco
e038aad3cc Avoid breaking people using requests.__version__
Using __version__ as a module breaks users who expect
requests.__version__ to be the version string.
2017-05-25 18:44:30 -05:00
Kenneth Reitz
4f8f4b5fb3 Merge pull request #4063 from kennethreitz/version
fix rtd
2017-05-25 16:24:02 -07:00
Kenneth Reitz
ce882a2eae fix rtd 2017-05-25 19:07:48 -04:00
Kenneth Reitz
f581dc95a9 Merge pull request #4059 from kennethreitz/version
__version__.py
2017-05-25 09:39:43 -07:00
Kenneth Reitz
7abfd92aea take a page out of @sigmavirus42's book 2017-05-25 11:46:12 -04:00
Kenneth Reitz
9fbfd22f6b take a page out of @sigmavirus42's book 2017-05-25 11:46:00 -04:00
Kenneth Reitz
e634ab73b2 better '' 2017-05-25 11:33:04 -04:00
Kenneth Reitz
3e32356716 __version__.py 2017-05-25 11:31:38 -04:00
Kenneth Reitz
539302a17d Update README.rst 2017-05-25 10:47:13 -04:00
Cory Benfield
037108178c Merge pull request #4056 from Lukasa/pytest-httpbin-fix
Disable pytest messing with warnings.
2017-05-24 10:46:11 -07:00
Cory Benfield
f3d310b299 Turns out @kennethreitz suprise-broke the CI 2017-05-24 10:20:07 -07:00
Cory Benfield
874bca97cb Disable pytest messing with warnings.
We may be able to remove this if pytest resolves pytest-dev/pytest#2430
2017-05-24 10:04:56 -07:00
Kenneth Reitz
dbb67a1310 Update __init__.py 2017-05-24 08:50:22 -07:00
Ilkka Tuohela
a9470fe31f Fix regression in API caused by commit 85400d8d67
- The added optional parameter changes API and should default to None

    This utility call is used by for example requestbuilder package directly
    which breaks because it passes only one argument to the function as it
    used to be.
2017-05-24 08:47:46 +03:00
Kenneth Reitz
0ba21a79c4 progress 2017-05-22 16:08:01 -07:00
Kenneth Reitz
66293b830a progress 2017-05-22 15:38:17 -07:00
Kenneth Reitz
6fb9b1ce53 fix lack of taste
Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
2017-05-21 23:25:18 -07:00
Kenneth Reitz
2772413f3d Update index.rst 2017-05-21 08:25:50 -07:00
Cory Benfield
ba63e50ecd Merge pull request #4041 from jdufresne/bdist_wheel
Add setup.cfg to declare wheel as universal
2017-05-20 08:11:11 -07:00
Jon Dufresne
2c71f2d520 Add setup.cfg to declare wheel as universal
As the project is pure Python, a built wheel should always be universal,
so define in the project globally. Can remove --universal command from
Makefile.

See:

http://pythonwheels.com/
2017-05-20 07:39:09 -07:00
Cory Benfield
fb3f2a030f Merge branch 'kaptajnen-master' 2017-05-18 09:05:03 -07:00
Jonas Laursen
00c6ad58b7 Simplify fix for #4025 2017-05-18 09:04:34 -07:00
Jonas Laursen
af66521381 Fix #4025 2017-05-18 09:04:34 -07:00
Ian Cordasco
a8bfa82801 Merge pull request #4026 from floppym/sdist-tests
Include tests in sdist tarball
2017-05-18 09:50:40 -05:00
Ian Cordasco
6ab6a18ab2 Merge pull request #4033 from Lukasa/issue/4030
Test that the readme renders in CI.
2017-05-17 20:41:00 -05:00
Ian Cordasco
570c4c83a5 Amend the syntax for skipping the readme check 2017-05-17 20:06:42 -05:00
Cory Benfield
e2142a1e54 Alex said this would work 2017-05-17 18:02:28 -07:00
Ian Cordasco
52a2efa2ae Avoid verifying the README.rst on Python 2.6
readme-render does not appear to support Python 2.6. This causes tests to fail
on Travis' 2.6 environment.
2017-05-17 19:54:31 -05:00
Ian Cordasco
f88e573c18 Merge branch 'master' into issue/4030 2017-05-17 19:36:49 -05:00
Cory Benfield
da29295369 Merge pull request #4036 from nateprewitt/pin_sphinx
Pin sphinx
2017-05-17 15:47:48 -07:00
Nate Prewitt
dbdbffd7f5 Stop creating Pipfile.lock on every make.
Pipenv used to require the file to be locked on each individual platform,
but as of v4.0.0, that is no longer necessary. Removing the forced call
to lock will speed up builds in CI.
2017-05-17 13:21:11 -07:00
Nate Prewitt
a3f2972c4f Temporarily cap Sphinx at 1.5.5 for Python 2.6 compatibility 2017-05-17 13:20:19 -07:00
Cory Benfield
1553770014 Fixup broken changelog 2017-05-17 10:54:06 -07:00
Cory Benfield
37ef88885c Test the readme in travis 2017-05-17 10:46:05 -07:00
Cory Benfield
2cb07872fe Add a makefile target for testing the readme 2017-05-17 10:44:14 -07:00
Mike Gilbert
2667c772b9 Include tests in sdist tarball
Fixes: https://github.com/kennethreitz/requests/issues/4024
2017-05-16 18:59:23 -04:00
Cory Benfield
0280a18b53 Merge pull request #4015 from nateprewitt/update_manifest
remove old test_requests.py listing from MANIFEST.in
2017-05-10 20:04:03 +01:00
Nate Prewitt
f4b90827b0 remove old test_requests.py listing from MANIFEST.in 2017-05-10 09:58:22 -06:00
Cory Benfield
e4693eba4f v2.14.2 2017-05-10 15:04:22 +01:00
Cory Benfield
2e496c3e1d Merge pull request #4014 from Lukasa/even-more-compat
Remove range operators from markers.
2017-05-10 15:02:54 +01:00
Cory Benfield
f3f4c3e20a Remove range operators from markers 2017-05-10 14:19:46 +01:00
21 changed files with 238 additions and 207 deletions

View File

@@ -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
View File

@@ -0,0 +1,3 @@
Be cordial or be on your way.
https://www.kennethreitz.org/essays/be-cordial-or-be-on-your-way

View File

@@ -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.

View File

@@ -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

View File

@@ -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

View File

@@ -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
View File

@@ -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"
}
}
}
}

View File

@@ -84,7 +84,6 @@ Requests is ready for today's web.
- Streaming Downloads
- ``.netrc`` Support
- Chunked Requests
- Thread-safety
Requests officially supports Python 2.62.7 & 3.33.7, and runs great on PyPy.

View File

@@ -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.

View File

@@ -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.62.7 & 3.33.7, and runs great on PyPy.

View File

@@ -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
View File

@@ -0,0 +1,2 @@
[pytest]
addopts = -p no:warnings

View File

@@ -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
View 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'✨ 🍰 ✨'

View File

@@ -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))

View 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):

View File

@@ -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

View File

@@ -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.

2
setup.cfg Normal file
View File

@@ -0,0 +1,2 @@
[bdist_wheel]
universal = 1

View File

@@ -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'],
},
)

View File

@@ -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: