Merge branch 'master' of https://github.com/requests/requests
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Kenneth Reitz · committed by Kenneth Reitz · parents e5666b9, 554a210 · Browse files · 5 files·+28 added−8 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+28 added−8 removed
- tests:+10 added−3 removed
- other:+18 added−5 removed
Provenance
- Commit
88dc335- Tree
d543233- Author
Kenneth Reitz <me@kennethreitz.org>- Committer
Kenneth Reitz <me@kennethreitz.org>- Parent 1
e5666b9- Parent 2
554a210
5 files changed+28 added−8 removed
modified:requests/__version__.py+2 added-2 removed
3 unmodified lines4 5 __title__ = 'requests'6 __description__ = 'Python HTTP for Humans.'7 __url__ = 'http://python-requests.org'8-__version__ = '2.18.3'9-__build__ = 0x0218038+__version__ = '2.18.4'9+__build__ = 0x02180410 __author__ = 'Kenneth Reitz'11 __author_email__ = 'me@kennethreitz.org'12 __license__ = 'Apache 2.0'13 __copyright__ = 'Copyright 2017 Kenneth Reitz'1 unmodified linemodified:requests/utils.py+7 added-3 removed
741 unmodified lines742 })743 744 745 def parse_header_links(value):746- """Return a dict of parsed link headers proxies.746+ """Return a list of parsed link headers proxies.747 748 i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg"749 750 :rtype: list2 unmodified lines753 links = []754 755 replace_chars = ' \'"'756 757+ value = value.strip(replace_chars)758+ if not value:759+ return links760+761 for val in re.split(', *<', value):762 try:763 url, params = val.split(';', 1)764 except ValueError:106 unmodified lines871 try:872 if not pat.match(value):873 raise InvalidHeader("Invalid return character or leading space in header: %s" % name)874 except TypeError:871- raise InvalidHeader("Header value %s must be of type str or bytes, "872- "not %s" % (value, type(value)))875+ raise InvalidHeader("Value for header {%s: %s} must be of type str or "876+ "bytes, not %s" % (name, value, type(value)))877 878 879 def urldefragauth(url):880 """28 unmodified linesmodified:tests/test_requests.py+6 added-3 removed
1399 unmodified lines1400 headers_dict = {'bar': {'foo': 'bar'}}1401 headers_list = {'baz': ['foo', 'bar']}1402 1403 # Test for int1404- with pytest.raises(InvalidHeader):1404+ with pytest.raises(InvalidHeader) as excinfo:1405 r = requests.get(httpbin('get'), headers=headers_int)1406+ assert 'foo' in str(excinfo.value)1407 # Test for dict1407- with pytest.raises(InvalidHeader):1408+ with pytest.raises(InvalidHeader) as excinfo:1409 r = requests.get(httpbin('get'), headers=headers_dict)1410+ assert 'bar' in str(excinfo.value)1411 # Test for list1410- with pytest.raises(InvalidHeader):1412+ with pytest.raises(InvalidHeader) as excinfo:1413 r = requests.get(httpbin('get'), headers=headers_list)1414+ assert 'baz' in str(excinfo.value)1415 1416 def test_header_no_return_chars(self, httpbin):1417 """Ensure that a header containing return character sequences raise an1418 exception. Otherwise, multiple headers are created from single string.971 unmodified linesmodified:tests/test_utils.py+4 added
496 unmodified lines497 {'url': 'http:/.../front.jpeg', 'type': 'image/jpeg'},498 {'url': 'http://.../back.jpeg'}499 ]500 ),501+ (502+ '',503+ []504+ ),505 ))506 def test_parse_header_links(value, expected):507 assert parse_header_links(value) == expected508 176 unmodified linesmodified:HISTORY.rst+9 added
8 unmodified lines9 **Improvements**10 11 **Bugfixes**12 13+- Parsing empty ``Link`` headers with ``parse_header_links()`` no longer return one bogus entry14+15+2.18.4 (2017-08-15)16++++++++++++++++++++17+18+**Improvements**19+20+- Error messages for invalid headers now include the header name for easier debugging21+22 **Dependencies**23 24 - We now support idna v2.6.25 1511 unmodified lines