D-Bus message header fields
smcv at collabora.com
Tue Sep 18 15:08:42 UTC 2018
On Tue, 18 Sep 2018 at 07:32:08 -0400, Felipe Gasper wrote:
> Why are D-Bus message headers defined as an array of structs rather than a dict?
If you want to know, I'd suggest researching in git history. I suspect
that the answer might be that header fields were invented before dict
entries. (But I could be wrong.)
> Is it intended that duplicate headers be used? Or is it safe for a new client implementation to treat the message headers as a dictionary?
The reference implementation of D-Bus considers duplicate headers
to be invalid (try `git grep DBUS_INVALID_HEADER_FIELD_APPEARS_TWICE`),
so dbus-daemon will close connections that try to send a message with
duplicate headers. As a result, we'll probably never want to use duplicate
headers - we'd be more likely to define a header whose value is an array.
However, client implementations probably shouldn't provide an API to
access header fields that the client implementor doesn't know about yet,
because their possible values and semantics are also not known until the
D-Bus Specification defines them. (An API like Message.get_interface()
is good, but Message.get_header(42) is inadvisable.)
More information about the dbus