Merge pull request #38 from nvllsvm/link

Change HTTPResponse.links to return empty list when Link header is not present
This commit is contained in:
dave-shawley 2021-09-15 15:57:04 -04:00 committed by GitHub
commit 19d4bd5a26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View file

@ -1,6 +1,10 @@
Version History Version History
=============== ===============
Next
----
- Change ``HTTPResponse.links`` to return empty list when ``Link`` header is not present
`2.4.1`_ Nov 30 2020 `2.4.1`_ Nov 30 2020
-------------------- --------------------
- Make request retry timeout configurable - Make request retry timeout configurable

View file

@ -152,8 +152,8 @@ class HTTPResponse:
""" """
if not self._responses: if not self._responses:
return None return None
if 'Link' in self._responses[-1].headers:
links = [] links = []
if 'Link' in self._responses[-1].headers:
for l in headers.parse_link(self._responses[-1].headers['Link']): for l in headers.parse_link(self._responses[-1].headers['Link']):
link = {'target': l.target} link = {'target': l.target}
link.update({k: v for (k, v) in l.parameters}) link.update({k: v for (k, v) in l.parameters})

View file

@ -258,7 +258,7 @@ class MixinTestCase(testing.AsyncHTTPTestCase):
'foo': ['bar'], 'foo': ['bar'],
'status_code': ['200'] 'status_code': ['200']
}) })
self.assertIsNone(response.links) self.assertEqual(response.links, [])
@testing.gen_test @testing.gen_test
def test_post(self): def test_post(self):