Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c398ab0e7d | ||
|
|
7d2dfa8684 | ||
|
|
6f659a4179 | ||
|
|
402a55b647 |
12
HISTORY.rst
12
HISTORY.rst
@@ -3,6 +3,18 @@
|
||||
Release History
|
||||
---------------
|
||||
|
||||
2.12.3 (2016-12-01)
|
||||
+++++++++++++++++++
|
||||
|
||||
**Bugfixes**
|
||||
|
||||
- Fixed regression from v2.12.1 for URLs with schemes that begin with "http".
|
||||
These URLs have historically been processed as though they were HTTP-schemed
|
||||
URLs, and so have had parameters added. This was removed in v2.12.2 in an
|
||||
overzealous attempt to resolve problems with IDNA-encoding those URLs. This
|
||||
change was reverted: the other fixes for IDNA-encoding have been judged to
|
||||
be sufficient to return to the behaviour Requests had before v2.12.0.
|
||||
|
||||
2.12.2 (2016-11-30)
|
||||
+++++++++++++++++++
|
||||
|
||||
|
||||
@@ -41,8 +41,8 @@ is at <http://python-requests.org>.
|
||||
"""
|
||||
|
||||
__title__ = 'requests'
|
||||
__version__ = '2.12.2'
|
||||
__build__ = 0x021202
|
||||
__version__ = '2.12.3'
|
||||
__build__ = 0x021203
|
||||
__author__ = 'Kenneth Reitz'
|
||||
__license__ = 'Apache 2.0'
|
||||
__copyright__ = 'Copyright 2016 Kenneth Reitz'
|
||||
|
||||
@@ -347,9 +347,9 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
||||
url = url.lstrip()
|
||||
|
||||
# Don't do any URL preparation for non-HTTP schemes like `mailto`,
|
||||
# `data`, `http+unix` etc to work around exceptions from `url_parse`,
|
||||
# which handles RFC 3986 only.
|
||||
if ':' in url and not url.lower().startswith(('http://', 'https://')):
|
||||
# `data` etc to work around exceptions from `url_parse`, which
|
||||
# handles RFC 3986 only.
|
||||
if ':' in url and not url.lower().startswith('http'):
|
||||
self.url = url
|
||||
return
|
||||
|
||||
|
||||
@@ -2177,18 +2177,72 @@ class TestPreparingURLs(object):
|
||||
r.prepare()
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'protocol, url',
|
||||
'input, expected',
|
||||
(
|
||||
("http+unix://", b"http+unix://%2Fvar%2Frun%2Fsocket/path"),
|
||||
("http+unix://", u"http+unix://%2Fvar%2Frun%2Fsocket/path"),
|
||||
("mailto", b"mailto:user@example.org"),
|
||||
("mailto", u"mailto:user@example.org"),
|
||||
("data", b"data:SSDimaUgUHl0aG9uIQ=="),
|
||||
(
|
||||
b"http+unix://%2Fvar%2Frun%2Fsocket/path",
|
||||
u"http+unix://%2fvar%2frun%2fsocket/path",
|
||||
),
|
||||
(
|
||||
u"http+unix://%2Fvar%2Frun%2Fsocket/path",
|
||||
u"http+unix://%2fvar%2frun%2fsocket/path",
|
||||
),
|
||||
(
|
||||
b"mailto:user@example.org",
|
||||
u"mailto:user@example.org",
|
||||
),
|
||||
(
|
||||
u"mailto:user@example.org",
|
||||
u"mailto:user@example.org",
|
||||
),
|
||||
(
|
||||
b"data:SSDimaUgUHl0aG9uIQ==",
|
||||
u"data:SSDimaUgUHl0aG9uIQ==",
|
||||
)
|
||||
)
|
||||
)
|
||||
def test_url_passthrough(self, protocol, url):
|
||||
session = requests.Session()
|
||||
session.mount(protocol, HTTPAdapter())
|
||||
p = requests.Request('GET', url=url)
|
||||
p.prepare()
|
||||
assert p.url == url
|
||||
def test_url_mutation(self, input, expected):
|
||||
"""
|
||||
This test validates that we correctly exclude some URLs from
|
||||
preparation, and that we handle others. Specifically, it tests that
|
||||
any URL whose scheme doesn't begin with "http" is left alone, and
|
||||
those whose scheme *does* begin with "http" are mutated.
|
||||
"""
|
||||
r = requests.Request('GET', url=input)
|
||||
p = r.prepare()
|
||||
assert p.url == expected
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'input, params, expected',
|
||||
(
|
||||
(
|
||||
b"http+unix://%2Fvar%2Frun%2Fsocket/path",
|
||||
{"key": "value"},
|
||||
u"http+unix://%2fvar%2frun%2fsocket/path?key=value",
|
||||
),
|
||||
(
|
||||
u"http+unix://%2Fvar%2Frun%2Fsocket/path",
|
||||
{"key": "value"},
|
||||
u"http+unix://%2fvar%2frun%2fsocket/path?key=value",
|
||||
),
|
||||
(
|
||||
b"mailto:user@example.org",
|
||||
{"key": "value"},
|
||||
u"mailto:user@example.org",
|
||||
),
|
||||
(
|
||||
u"mailto:user@example.org",
|
||||
{"key": "value"},
|
||||
u"mailto:user@example.org",
|
||||
),
|
||||
)
|
||||
)
|
||||
def test_parameters_for_nonstandard_schemes(self, input, params, expected):
|
||||
"""
|
||||
Setting paramters for nonstandard schemes is allowed if those schemes
|
||||
begin with "http", and is forbidden otherwise.
|
||||
"""
|
||||
r = requests.Request('GET', url=input, params=params)
|
||||
p = r.prepare()
|
||||
assert p.url == expected
|
||||
|
||||
|
||||
Reference in New Issue
Block a user