diff --git a/docs/history.rst b/docs/history.rst index 5961d56..f2a776f 100644 --- a/docs/history.rst +++ b/docs/history.rst @@ -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 diff --git a/sprockets/mixins/http/__init__.py b/sprockets/mixins/http/__init__.py index 1548151..bec12d8 100644 --- a/sprockets/mixins/http/__init__.py +++ b/sprockets/mixins/http/__init__.py @@ -152,13 +152,13 @@ class HTTPResponse: """ 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): diff --git a/tests.py b/tests.py index a8d0bce..f6906dd 100644 --- a/tests.py +++ b/tests.py @@ -258,7 +258,7 @@ class MixinTestCase(testing.AsyncHTTPTestCase): 'foo': ['bar'], 'status_code': ['200'] }) - self.assertIsNone(response.links) + self.assertEqual(response.links, []) @testing.gen_test def test_post(self):