Re: D-Bus message header fields
Felipe Gasper <felipe-c4PQK5fb7feI/[email protected]>
| Newsgroups | gmane.comp.freedesktop.dbus |
|---|---|
| Message-ID | <[email protected]> |
> On Sep 18, 2018, at 11:35 AM, Simon McVittie <[email protected]> wrote: > > On Tue, 18 Sep 2018 at 11:13:44 -0400, Felipe Gasper wrote: >>> On Sep 18, 2018, at 11:08 AM, Simon McVittie <[email protected]> wrote: >>>> 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. >> >> Would there be any problem, then, with marshaling/unmarshaling headers as “yyyyuua{yv}”? > > Why would you? The spec says the header fields are an array of pairs, > so unmarshalling them as anything other than an array of pairs seems an > odd thing to want to do? > > (You don't have to store them in the same way you would present an array > of pairs to users of your implementation, of course.) I am new to both the protocol and its specification, but FWIW, it seems like the protocol uses those header fields as a dictionary in practice, as in your previous example of a get_interface() method: look up by index, no dupes allowed. I suppose it’s implementation-dependent, but it would seem a bit simpler, conceptually as well as in practice, to marshal/unmarshal *as* a dict rather than as an array of pairs that we use as a dict. -F _______________________________________________ dbus mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dbus