Library for parsing RFC 8288 "Link" HTTP headers
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file httplink-0.2.0-py3-none-any.whl.
File metadata
- Download URL: httplink-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4688080f92306dbb3faa71ea8232e1e8cb4a4a7f543bc9663b05dca8a2820c1
|
|
| MD5 |
f7a52c2431d662a368d6735320693f94
|
|
| BLAKE2b-256 |
343fd43dbecbec06fe5654b85b2f5f562c877586dfcde587dd4954d9eeb07f76
|