Skip to content

Commit

Permalink
Merge pull request #38 from nvllsvm/link
Browse files Browse the repository at this point in the history
Change HTTPResponse.links to return empty list when Link header is not present
  • Loading branch information
dave-shawley committed Sep 15, 2021
2 parents 3e1e1e4 + 5324f7d commit 19d4bd5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions docs/history.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Version History
===============

Next
----
- Change ``HTTPResponse.links`` to return empty list when ``Link`` header is not present

`2.4.1`_ Nov 30 2020
--------------------
- Make request retry timeout configurable
Expand Down
4 changes: 2 additions & 2 deletions sprockets/mixins/http/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ def links(self):
"""
if not self._responses:
return None
links = []
if 'Link' in self._responses[-1].headers:
links = []
for l in headers.parse_link(self._responses[-1].headers['Link']):
link = {'target': l.target}
link.update({k: v for (k, v) in l.parameters})
links.append(link)
return links
return links

@property
def ok(self):
Expand Down
2 changes: 1 addition & 1 deletion tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def test_get(self):
'foo': ['bar'],
'status_code': ['200']
})
self.assertIsNone(response.links)
self.assertEqual(response.links, [])

@testing.gen_test
def test_post(self):
Expand Down

0 comments on commit 19d4bd5

Please sign in to comment.