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
===============
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

View file

@ -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):

View file

@ -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):