Skip to content
Myr

Added in a link handler as per issue #711

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Rhys Elsmore · committed by Rhys Elsmore · parent 2e71497 · Browse files · 1 file+33 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+33 added−0 removed

  • other:+33 added−0 removed

1 file+33 added−0 removed

modified:requests/utils.py+33 added
516 unmodified lines
517 'python-requests/%s' % __version__,518 '%s/%s' % (_implementation, _implementation_version),519 '%s/%s' % (platform.system(), platform.release()),520 ])521522def parse_header_links(value):523 """Return a dict of parsed link headers proxies.524525 i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg"526527 """528 529 links = []530531 replace_chars = " '\""532533 for val in value.split(","):534 try:535 url, params = val.split(";", 1)536 except ValueError:537 url, params = val, ''538539 link = {}540541 link["url"] = url.strip("<> '\"")542543 for param in params.split(";"):544 try:545 key,value = param.split("=")546 except ValueError:547 break548 549 link[key.strip(replace_chars)] = value.strip(replace_chars)550551 links.append(link)552553 return links