skip to navigation
skip to content

LinkHeader 0.4.3

Parse and format link headers according to RFC 5988 "Web Linking"

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("", rel="self"),
...                                   Link("", rel="up")]))
>>> headers['Link']
'<>; rel=self, <>; rel=up'
>>> parse(headers['Link'])
LinkHeader([Link('', rel='self'), Link('', 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()
[['', [['rel', 'self']]], ['', [['rel', 'up']]]]
>>> str(LinkHeader([['', [['rel', 'self']]],
...                 ['', [['rel', 'up']]]]))
'<>; rel=self, <>; rel=up'
File Type Py Version Uploaded on Size
LinkHeader-0.4.3.tar.gz (md5) Source 2015-09-10 4KB
  • Downloads (All Versions):
  • 20 downloads in the last day
  • 263 downloads in the last week
  • 1363 downloads in the last month