Parse and format link headers according to RFC 5988 "Web Linking"
Project description
Parse and format link headers according to RFC 5988 “Web Linking”.
Usage (assuming a suitable headers object in the environment):
>>> headers['Link'] = str(LinkHeader([Link("http://example.com/foo", rel="self"),
... Link("http://example.com", rel="up")]))
>>> headers['Link']
'<http://example.com/foo>; rel=self, <http://example.com>; rel=up'
>>> parse(headers['Link'])
LinkHeader([Link('http://example.com/foo', rel='self'), Link('http://example.com', rel='up')])
Blank and missing values roundtrip correctly:
>>> format_link(parse('</s/1>; obs; if="core.s"; foo=""'))
'<</s/1>; obs; if=core.s; foo="">'
Conversions to and from json-friendly list-based structures are also provided:
>>> parse(headers['Link']).to_py() [['http://example.com/foo', [['rel', 'self']]], ['http://example.com', [['rel', 'up']]]] >>> str(LinkHeader([['http://example.com/foo', [['rel', 'self']]], ... ['http://example.com', [['rel', 'up']]]])) '<http://example.com/foo>; rel=self, <http://example.com>; rel=up'
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
LinkHeader-0.4.3.tar.gz
(4.2 kB
view details)
File details
Details for the file LinkHeader-0.4.3.tar.gz.
File metadata
- Download URL: LinkHeader-0.4.3.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fbbc35c0ba3fbbc530571db7e1c886e7db3d718b29b345848ac9686f21b50c3
|
|
| MD5 |
7d23eb803c206bdb78e8dc360a104422
|
|
| BLAKE2b-256 |
27d4eb1da743b2dc825e936ef1d9e04356b5701e3a9ea022c7aaffdf4f6b0594
|