kennethreitz/requests — pull request #801 by rhyselsmore (2012-08-20 14:49:29+00:00)
Title: Added in a link handler as per issue #711

Basic Basic handling of links. So far has very basic error handling, and might not cater for some cases. Handles the syntax of link headers that are demonstrated below.

>>> from requests.utils import parse_header_links
>>> parse_header_links('; rel=front; type="image/jpeg",; rel=back;type="image/jpeg"')
[{'url': 'http:/.../front.jpeg', 'type': 'image/jpeg', 'rel': 'front'}, {'url': 'http://.../back.jpeg', 'type': 'image/jpeg', 'rel': 'back'}]
>>> parse_header_links(';')
[{'url': 'http:/.../front.jpeg'}]
>>> parse_header_links('')
[{'url': 'http:/.../front.jpeg'}]
>>> parse_header_links('; a=t')
[{'url': 'http:/.../front.jpeg', 'a': 't'}]