Skip to content
Myr

Merge pull request #4245 from remram44/fix-headers-links

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fix parse_header_links on empty header

authored by Cory Benfield · committed by GitHub · parents af9dd61, 8e411d0 · Browse files · 3 files+11 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+11 added−1 removed

  • tests:+4 added−0 removed
  • other:+7 added−1 removed

3 files+11 added−1 removed

modified:requests/utils.py+5 added-1 removed
741 unmodified lines
742 })743744745def parse_header_links(value):746 """Return a dict of parsed link headers proxies.746 """Return a list of parsed link headers proxies.747748 i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg"749750 :rtype: list
2 unmodified lines
753 links = []754755 replace_chars = ' \'"'756757 value = value.strip(replace_chars)758 if not value:759 return links760761 for val in re.split(', *<', value):762 try:763 url, params = val.split(';', 1)764 except ValueError:
144 unmodified lines
modified:tests/test_utils.py+4 added
496 unmodified lines
497 {'url': 'http:/.../front.jpeg', 'type': 'image/jpeg'},498 {'url': 'http://.../back.jpeg'}499 ]500 ),501 (502 '',503 []504 ),505 ))506def test_parse_header_links(value, expected):507 assert parse_header_links(value) == expected508
176 unmodified lines
modified:HISTORY.rst+2 added
8 unmodified lines
9**Improvements**1011**Bugfixes**1213- Parsing empty ``Link`` headers with ``parse_header_links()`` no longer return one bogus entry14152.18.4 (2017-08-15)16+++++++++++++++++++1718**Improvements**
1518 unmodified lines