Messages

class sipmessage.Message
static parse(data: bytes) Request | Response

Parse the given string into a Request or Response instance.

If parsing fails, a ValueError is raised.

class sipmessage.Request(method: str, uri: URI, body: bytes = b'')

A SIP request.

property accept: list[MediaType] | None

The Accept header values.

A None value indicates the header is absent, while an empty list indicates that no formats are acceptable.

RFC 3261 Section 20.1

property authorization: AuthCredentials | None

The Authorization header value.

RFC 3261 Section 20.7

body: bytes

The request body.

property call_id: str

The Call-ID header value.

RFC 3261 Section 20.8

property contact: list[Address]

The Contact header values.

RFC 3261 Section 20.10

property content_language: str | None

The Content-Language header value.

RFC 3261 Section 20.13

property content_length: int | None

The Content-Length header value.

RFC 3261 Section 20.14

property content_type: MediaType | None

The Content-Type header value.

RFC 3261 Section 20.15

property cseq: CSeq

The CSeq header value.

RFC 3261 Section 20.16

property date: datetime | None

The Date header value.

RFC 3261 Section 20.17

property expires: int | None

The Expires header value.

RFC 3261 Section 20.19

property from_address: Address

The From header value.

RFC 3261 Section 20.20

headers: Headers

The request headers in raw form. It is usually better to use the typed accessors.

property in_reply_to: list[str]

The In-Reply-To header value.

RFC 3261 Section 20.21

property max_forwards: int | None

The Max-Forwards header value.

RFC 3261 Section 20.22

method: str

The request method.

property min_expires: int | None

The Min-Expires header value.

RFC 3261 Section 20.23

property proxy_authenticate: AuthChallenge | None

The Proxy-Authenticate header value.

RFC 3261 Section 20.27

property proxy_authorization: AuthCredentials | None

The Proxy-Authorization header value.

RFC 3261 Section 20.28

property proxy_require: list[str]

The Proxy-Require header values.

RFC 3261 Section 20.29

property record_route: list[Address]

The Record-Route header values.

RFC 3261 Section 20.30

property require: list[str]

The Require header values.

RFC 3261 Section 20.32

property route: list[Address]

The Route header values.

RFC 3261 Section 20.34

property server: str | None

The Server header value.

RFC 3261 Section 20.35

property subject: str | None

The Subject header value.

RFC 3261 Section 20.36

property supported: list[str]

The Supported header values.

RFC 3261 Section 20.37

property to_address: Address

The To header value value.

RFC 3261 Section 20.39

property unsupported: list[str]

The Unsupported header values.

RFC 3261 Section 20.40

uri: URI

The request URI.

property user_agent: str | None

The User-Agent header value.

RFC 3261 Section 20.41

property via: list[Via]

The Via header values.

RFC 3261 Section 20.42

property www_authenticate: AuthChallenge | None

The WWW-Authenticate header value.

RFC 3261 Section 20.44

class sipmessage.Response(code: int, phrase: str, body: bytes = b'')

A SIP response.

property accept: list[MediaType] | None

The Accept header values.

A None value indicates the header is absent, while an empty list indicates that no formats are acceptable.

RFC 3261 Section 20.1

property authorization: AuthCredentials | None

The Authorization header value.

RFC 3261 Section 20.7

body: bytes

The response body.

property call_id: str

The Call-ID header value.

RFC 3261 Section 20.8

code: int

The response code.

property contact: list[Address]

The Contact header values.

RFC 3261 Section 20.10

property content_language: str | None

The Content-Language header value.

RFC 3261 Section 20.13

property content_length: int | None

The Content-Length header value.

RFC 3261 Section 20.14

property content_type: MediaType | None

The Content-Type header value.

RFC 3261 Section 20.15

property cseq: CSeq

The CSeq header value.

RFC 3261 Section 20.16

property date: datetime | None

The Date header value.

RFC 3261 Section 20.17

property expires: int | None

The Expires header value.

RFC 3261 Section 20.19

property from_address: Address

The From header value.

RFC 3261 Section 20.20

headers: Headers

The response headers in raw form. It is usually better to use the typed accessors.

property in_reply_to: list[str]

The In-Reply-To header value.

RFC 3261 Section 20.21

property max_forwards: int | None

The Max-Forwards header value.

RFC 3261 Section 20.22

property min_expires: int | None

The Min-Expires header value.

RFC 3261 Section 20.23

phrase: str

The response phrase.

property proxy_authenticate: AuthChallenge | None

The Proxy-Authenticate header value.

RFC 3261 Section 20.27

property proxy_authorization: AuthCredentials | None

The Proxy-Authorization header value.

RFC 3261 Section 20.28

property proxy_require: list[str]

The Proxy-Require header values.

RFC 3261 Section 20.29

property record_route: list[Address]

The Record-Route header values.

RFC 3261 Section 20.30

property require: list[str]

The Require header values.

RFC 3261 Section 20.32

property route: list[Address]

The Route header values.

RFC 3261 Section 20.34

property server: str | None

The Server header value.

RFC 3261 Section 20.35

property subject: str | None

The Subject header value.

RFC 3261 Section 20.36

property supported: list[str]

The Supported header values.

RFC 3261 Section 20.37

property to_address: Address

The To header value value.

RFC 3261 Section 20.39

property unsupported: list[str]

The Unsupported header values.

RFC 3261 Section 20.40

property user_agent: str | None

The User-Agent header value.

RFC 3261 Section 20.41

property via: list[Via]

The Via header values.

RFC 3261 Section 20.42

property www_authenticate: AuthChallenge | None

The WWW-Authenticate header value.

RFC 3261 Section 20.44

class sipmessage.Headers

A dictionary-like storage of SIP headers with support for multiple values.

add(key: str, value: str) None

Add a new header.

get(key: str, default: str | None = None) str | None

Return the first value for the given header or default.

getlist(key: str) list[str]

Return all the values for the given header.

keys() list[str]

Return the names of all the headers.

remove(key: str) None

Remove the given header.

set(key: str, value: str) None

Remove all values for the given header and replace them with the given value.

setlist(key: str, values: list[str]) None

Remove all values for the given header and replace them with the given values.