ursine
latest

Contents:

  • URI
  • Header
ursine
  • Docs »
  • Header
  • Edit on GitHub

Header¶

A SIP header wraps together a display name, sip URI, and header parameters, and so too does the ursine header, but the Header class also offers one utility - it can be used to ensure that a given header has a tag (randomly generating one and applying it if no tag exists and no tag to use is specified).

from ursine import Header, URI

hdr1 = Header('"Alice" <sip:localhost>;tag=foo')
hdr2 = Header('<sip:localhost>')

assert hdr1 == hdr2.with_display_name('Alice').with_tag('foo')
assert hdr1.with_display_name(None) == hdr2.with_tag('foo')

uri = URI.build(scheme='sip', host='localhost')
header_with_tag = Header.build(uri=uri).with_tag()

assert header_with_tag.tag is not None
class ursine.header.Header(header: str)¶

A SIP Header (Contact/To/From).

classmethod build(*, uri: ursine.uri.URI, display_name: Union[str, NoneType] = None, parameters: Union[typing.Dict[str, str], NoneType] = None, tag: Union[str, NoneType] = None) → ursine.header.Header¶

Build a new Header from kwargs.

with_display_name(display_name: str)¶

Create a new Header from self with a specific display name.

with_parameters(parameters: Dict[str, str])¶

Create a new Header from self with specific parameters.

with_tag(tag: Union[str, NoneType] = None)¶

Create a new Header from self guaranteed to have a tag.

If tag is defined the resulting Header will always have the given tag value, but if tag is specied or defaulted to None a new Header with a randomly generated tag will be returned.

with_uri(uri: ursine.uri.URI)¶

Create a new Header from self with a specific URI.

exception ursine.header.HeaderError¶
Previous

© Copyright 2018, Terry Kerr. Revision e425b262.

Built with Sphinx using a theme provided by Read the Docs.