Skip to main content

Python (>= 3.6) library for parsing RFC 8288 HTTP Link headers. Python 2 is not supported.

from httplink import parse_link_header
result = parse_link_header('''
   <https://example.com/foo/index.html>; rel=index;
   foo*=UTF-8'en'b%c3%a5r, </path#frag>;rel="what ever"
''')

## Target URL:
print(result['index'].target)
# https://example.com/foo/index.html

## Set of link relations:
print(result['index'].rel)
# {'index'}

## Decoded attribute value:
print(result['index']['foo'])
# bår

## Raw undecoded attributes:
print(result['index'].attributes)
# [('rel', 'index'), ('foo*', "UTF-8'en'b%c3%a5r")]

## Iterate over all links:
for link in result.links:
    print(link.rel, link.target)
# {'index'} https://example.com/foo/index.html
# {'ever', 'what'} /path#frag

Multiple Link headers can be parsed at the same time if you concatenate them with ,.

Redundant white space and comma delimiters are ignored.

["key"]-access is always case-insensitive.

Release files for httplink 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for httplink 0.2.0
File Interpreter ABI Platform
httplink-0.2.0-py3-none-any.whl Python 3 none any Details

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page